Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can't get value from readonly or disabled textbox control asp.net

Tags:

.net

null

asp.net

I created an uneditable control in asp.net using either of the folowing

<asp:TextBox ID="txtStartDate" runat="server" enabled="false"></asp:TextBox>
or
<asp:TextBox ID="txtStartDate" runat="server" readonly="true"></asp:TextBox>

am using a javascript popup to fill the textbox in the client side. the value is always null when i tried to retrieve it in codebehind

can anyone suggest a better way

like image 493
Smith Avatar asked Apr 19 '12 11:04

Smith


1 Answers

Try this

<asp:TextBox ID="txtStartDate" runat="server"></asp:TextBox>

Code Behind

 txtStartDate.Attributes.Add("readonly", "readonly");

Read more about How to retrieve read-only textbox's value in the code behind

like image 83
huMpty duMpty Avatar answered Nov 15 '22 02:11

huMpty duMpty