I have a textbox.In its onclick iam calling a javascript fn to call calendar.Texbox is readonly. Clicking on textbox calendar is coming and value is showing in textbox. But on clicking submit button where I have written code to save, there i am not getting value in textbox. What may be the reason for that?
我有一个文本框。在其onclick iam中调用javascript fn来调用calendar.Texbox是readonly。单击文本框日历即将到来,值将显示在文本框中。但是点击提交按钮,我已经编写了代码保存,我没有在文本框中获得价值。可能是什么原因?
5 个解决方案
#1
#2
I had this problem too, there is a really simple workaround
我也有这个问题,有一个非常简单的解决方法
Instead of making the textbox ReadOnly using properties option. Do it thru the code behind adding this code:
而不是使用属性选项使文本框ReadOnly。通过添加此代码后面的代码来执行此操作:
YourTextBox.Attributes.Add("readonly", "readonly");
#3
You can get the value by using
您可以使用获取值
Request.Form[YourTextBox.UniqueID]
#4
I'm guessing the textbox is disabled so that people have to use the calendar control to enter a date? The textbox is just for showing the selected date?
我猜测文本框已禁用,以便人们必须使用日历控件输入日期?文本框仅用于显示所选日期?
If you want the textbox to stay readonly (i.e. disabled client-side), have a hidden input that has the value you want to handle on the server is the way to go probably. So add an additional input for to the page. Use
如果您希望文本框保持只读(即禁用客户端),则可能有一个隐藏的输入具有您要在服务器上处理的值。因此,为页面添加其他输入。使用
<asp:HiddenField ... runat="server" />
So the client-side code that updates your readonly textbox will also update your hidden input.
因此,更新您的只读文本框的客户端代码也将更新您的隐藏输入。
#5
if readonly property is true, its not break your .cs call. you can use this as always:
如果readonly属性为true,则不会破坏.cs调用。你可以像往常一样使用它:
here are your inputs:
这是你的输入:
<asp:TextBox ID="txtBraid" runat="server" Text="Im sooo readonly" ReadOnly="True"></asp:TextBox>
<asp:Label ID="lblBraid" runat="server" Text="Im gonna change, i promise"></asp:Label>
on .cs page put these to onClick function or something:
在.cs页面上将这些放到onClick函数或其他东西:
lblBraid.Text = txtBraid.Text;
#1
I suspect that your text box has the disabled attribute instead of readonly which prevents it from posting its value to the server.
我怀疑您的文本框具有disabled属性而不是readonly,这会阻止它将其值发布到服务器。
#2
I had this problem too, there is a really simple workaround
我也有这个问题,有一个非常简单的解决方法
Instead of making the textbox ReadOnly using properties option. Do it thru the code behind adding this code:
而不是使用属性选项使文本框ReadOnly。通过添加此代码后面的代码来执行此操作:
YourTextBox.Attributes.Add("readonly", "readonly");
#3
You can get the value by using
您可以使用获取值
Request.Form[YourTextBox.UniqueID]
#4
I'm guessing the textbox is disabled so that people have to use the calendar control to enter a date? The textbox is just for showing the selected date?
我猜测文本框已禁用,以便人们必须使用日历控件输入日期?文本框仅用于显示所选日期?
If you want the textbox to stay readonly (i.e. disabled client-side), have a hidden input that has the value you want to handle on the server is the way to go probably. So add an additional input for to the page. Use
如果您希望文本框保持只读(即禁用客户端),则可能有一个隐藏的输入具有您要在服务器上处理的值。因此,为页面添加其他输入。使用
<asp:HiddenField ... runat="server" />
So the client-side code that updates your readonly textbox will also update your hidden input.
因此,更新您的只读文本框的客户端代码也将更新您的隐藏输入。
#5
if readonly property is true, its not break your .cs call. you can use this as always:
如果readonly属性为true,则不会破坏.cs调用。你可以像往常一样使用它:
here are your inputs:
这是你的输入:
<asp:TextBox ID="txtBraid" runat="server" Text="Im sooo readonly" ReadOnly="True"></asp:TextBox>
<asp:Label ID="lblBraid" runat="server" Text="Im gonna change, i promise"></asp:Label>
on .cs page put these to onClick function or something:
在.cs页面上将这些放到onClick函数或其他东西:
lblBraid.Text = txtBraid.Text;