当前位置:网站首页>C # set TextBox control not editable
C # set TextBox control not editable
2022-07-28 03:18:00 【Dusk and starry sky】
Preface
generally speaking ,Textbox There are two properties in which you can set to prevent editing , This is the most basic knowledge , It is also the first two methods I want to propose . The latter two methods are actually one , But it can be applied in different environments .
One 、ReadOnly attribute
Set this way ,Textbox Control restricts input , But you can read existing text , The style is also similar to that of normal use Textbox Agreement .
1、 Set... At the front end Readonly by true, The style is as follows :
<asp:TextBox ID=“TextBox1” runat=“server” ReadOnly=“true” Text=“ test ”></asp:TextBox>
2、 Set up... In the background Readonly by true, The style is as follows :
TextBox1.ReadOnly = true;
Two 、Enabled attribute
Setting this property will Textbox Control becomes grayed out , Do not click .
1、 Set... At the front end Enabled by false, The style is as follows :
<asp:TextBox ID=“TextBox1” runat=“server” Enabled=“false” Text=“ test ”></asp:TextBox>
2、 Set up... In the background Readonly by true, The style is as follows :
TextBox1.Enabled= false;
3、 ... and 、onfocus Method
Set up JS Events ,onfocus Event refers to the cursor moving to this control ,this.blur() Yes move the cursor away , In this way, we can achieve the purpose of editing , The code is as follows .
<asp:TextBox ID=“TextBox1” runat=“server” Text=“ test ” οnfοcus=“this.blur();”></asp:TextBox>
Four 、 Set up TextModel style
Use CSS Code , Set up TextModel attribute . Combine with the third , The advantage of this setting is that it can also achieve the purpose of non editing in some browsers , But it can guarantee the original "X" Sign exists , So you can also realize the purpose of clarifying the content of the control . Tested , stay IE Browser does not support this function , but Google The browser can .
The front-end code is as follows :
<asp:TextBox ID=“TextBox1” runat=“server” Text=“ test ” TextModel=“search” οnfοcus=“this.blur();”></asp:TextBox>
Css The style is as follows :
边栏推荐
- vba批量读取sql的create文来创建表
- els 键盘信息
- Redis实现分布式锁
- The digital twin smart building visualization platform realizes the integration of enterprise and public services in the park
- More than 50 interviews have been summarized, and notes and detailed explanations have been taken from April to June (including core test sites and 6 large factories)
- 基于JSP&Servlet实现的众筹平台系统
- The applet has obtained the total records and user locations in the database collection. How to use aggregate.geonear to arrange the longitude and latitude from near to far?
- stm32F407-------DSP学习
- 会议OA项目之我的审批&&签字功能
- 将Helm编写的Chart推送到Harbor仓库
猜你喜欢

Scheme sharing | experts gather to jointly explore accent AI speech recognition

PCB丝印如何摆?请查收这份手册!

More than 50 interviews have been summarized, and notes and detailed explanations have been taken from April to June (including core test sites and 6 large factories)

Engineering Geology Practice - engineering geology problem set

嵌入式开发:提示和技巧——用C进行防御性编程的最佳实践

MySQL index learning

C#实现弹出一个对话框的同时,后面的form不可用

Intelligent industrial design software company Tianfu C round financing of hundreds of millions of yuan

redis网络模型解析

QT official example: Fridge Magnets example
随机推荐
20条心灵鸡汤唯美句子,句句温情暖心!
线程基础
The digital twin smart building visualization platform realizes the integration of enterprise and public services in the park
基于JSP&Servlet实现的众筹平台系统
Scheme sharing | experts gather to jointly explore accent AI speech recognition
els 键盘信息
Redis通信协议--RESP协议
MySQL essay
Review basic knowledge points of engineering electromagnetic field
IronOCR for .NET 2022.8
《MySQL数据库进阶实战》读后感(SQL 小虚竹)
Qt官方示例:Fridge Magnets Example(冰箱贴)
Redis5种数据结构解析
综合 案例
Note that these regions cannot take the NPDP exam in July
stm32F407-------DSP学习
[uni app advanced practice] take you hand-in-hand to learn the development of a purely practical complex project 2/100
Design of the multi live architecture in different places of the king glory mall
ThreadLocal使用场景
Industry insight | is speech recognition really beyond human ears?