textBox1.Enabled = false; or
textBox1.ReadOnly = true;
Each of these lines of code will lock the text box in a different way. Use the Enabled property if you want the user to have no access to the contained text, and use the ReadOnly property if you want to allow the user to highlight and copy the text. In either
case, the user will not be able to edit the text.
Best Regards,
Amy Peng
Please mark the replies as answers if they help or unmark if not.
Feedback to us
Hi, after i write <asp:TextBox ID="WMSBoxID" runat="server" ReadOnly></asp:TextBox>, the textbox no available for me to text. is it possible text it after block. Example - scan the barcode in textbox,when i turn the next textbox, it will
lock.
As far as I understood your problem you want your textbox to be locked when text changed in textbox and focus moved to next control here is solution if above is what you looking for.
Add TextChanged event with textbox you want to lock, make sure textbox AutoPostBack property must be true.
Hi, after i write in the textchange event with textbox in code behind file, it had an error. kindly advise thank you.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Collections;
using System.Configuration;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
namespace acmkweb.WMS
{
public partial class WMSMI : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
FillTransactionTypeList();
SystemDate();
string stat = Request.QueryString["stat"];
if (stat == "insert")
{
StatLabel.Text = "New Record have been Insert";
}
caulson
Member
23 Points
65 Posts
How to write in C# code to lock a text box
Jan 25, 2013 06:10 AM|LINK
Dear All ,
May i know how to write in C# code lock a text box after i used a bar code device scan a code number without modify ? thank you.
Primillo
Star
8727 Points
1679 Posts
Re: How to write in C# code to lock a text box
Jan 25, 2013 06:22 AM|LINK
Use the read only property:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.textbox_properties.aspx
Primillo
http://www.facebook.com/programandopuntonet
Amy Peng - M...
Star
10122 Points
958 Posts
Microsoft
Re: How to write in C# code to lock a text box
Jan 27, 2013 02:35 PM|LINK
Hi,
Use one of the following lines of code:
textBox1.Enabled = false; or
textBox1.ReadOnly = true;
Each of these lines of code will lock the text box in a different way. Use the Enabled property if you want the user to have no access to the contained text, and use the ReadOnly property if you want to allow the user to highlight and copy the text. In either case, the user will not be able to edit the text.
Best Regards,
Amy Peng
Feedback to us
Develop and promote your apps in Windows Store
necro_mancer
Star
8017 Points
1574 Posts
Re: How to write in C# code to lock a text box
Jan 28, 2013 12:04 AM|LINK
hi there,
I normally use textBox.enabled = false.
Please mark this response as an "answer" if it helps. Thank you. :)
Professional SQL 2008 R2 Service
caulson
Member
23 Points
65 Posts
Re: How to write in C# code to lock a text box
Jan 28, 2013 12:44 AM|LINK
Hi, thank you for reply, is it write as below code ? kindly advise.. thank you.
<asp:TableRow ID="TableRow3" runat="server" ForeColor="Teal">
<asp:TableHeaderCell BorderColor="Black" BorderWidth="1" BackColor="#0C0C25" ForeColor="White">Box ID :</asp:TableHeaderCell>
<asp:TableHeaderCell BorderColor="Black" BorderWidth="1" BackColor="ControlLight">
<asp:TextBox ID="WMSBoxID" runat="server" TextBoxID.ReadOnly = "true"></asp:TextBox
xmione
Member
344 Points
80 Posts
Re: How to write in C# code to lock a text box
Jan 28, 2013 04:19 AM|LINK
Hi caulson,
You can write it as below:
<asp:TextBox ID="WMSBoxID" runat="server" ReadOnly></asp:TextBox>
Regards
Please mark as Answer if this helped you with your problem.
caulson
Member
23 Points
65 Posts
Re: How to write in C# code to lock a text box
Jan 28, 2013 04:49 AM|LINK
Hi, after i write <asp:TextBox ID="WMSBoxID" runat="server" ReadOnly></asp:TextBox>, the textbox no available for me to text. is it possible text it after block. Example - scan the barcode in textbox,when i turn the next textbox, it will lock.
thank you.
kaushikmahet...
Contributor
3750 Points
886 Posts
Re: How to write in C# code to lock a text box
Jan 28, 2013 04:53 AM|LINK
textboxname.Enable=false
Remember to click Mark as Answer on the post that helps to others.
alam.net
Member
140 Points
47 Posts
Re: How to write in C# code to lock a text box
Jan 28, 2013 05:03 AM|LINK
Hi caulson,
As far as I understood your problem you want your textbox to be locked when text changed in textbox and focus moved to next control here is solution if above is what you looking for.
Add TextChanged event with textbox you want to lock, make sure textbox AutoPostBack property must be true.
default.aspx
<asp:TextBox ID="TextBox1" runat="server" AutoPostBack="True"
ontextchanged="TextBox1_TextChanged"></asp:TextBox>
code behind C#: default.aspx.cs
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
TextBox1.Enabled = false;
}
mark as answer and help others
Mark Answer Help Others;
else
I am sorry I didn't understand your problem;
caulson
Member
23 Points
65 Posts
Re: How to write in C# code to lock a text box
Jan 28, 2013 05:41 AM|LINK
Hi, after i write in the textchange event with textbox in code behind file, it had an error. kindly advise thank you.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Collections;
using System.Configuration;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
namespace acmkweb.WMS
{
public partial class WMSMI : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
FillTransactionTypeList();
SystemDate();
string stat = Request.QueryString["stat"];
if (stat == "insert")
{
StatLabel.Text = "New Record have been Insert";
}
}
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
TextBox1.Enabled = false;
}