can't get value from readonly or disabled text

2019-04-30 03:06发布

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

1条回答
唯我独甜
2楼-- · 2019-04-30 03:51

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

查看更多
登录 后发表回答