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

橙三吉。 提交于 2019-12-22 07:37:30

问题


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:


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



来源:https://stackoverflow.com/questions/10227003/cant-get-value-from-readonly-or-disabled-textbox-control-asp-net

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!