update panel is not working properly
I have an update panel. inside this panel, there are two controls a label and a dropdown.
I'm changing the label's value using javascript. the dropdown has a selectIndexChanged event.
whenever this event fires it clears off the label's value i set using javascript.
What's going wrong here?
--------Edit------------
Thanks for the responses. I understand that since label is not a user entry field the value is not retained on postback. Let me explain my situation.
There is a form
It has a textbox, an icon, and a dropdown that has an event. All these items are present inside an update panel.
Clicking on the icon will open popup. the text box value is populated from the popup using javascript.
I d开发者_如何学Cont want the user to edit this textbox's value. So i changed readonly. It doesn't retain teh value.
is there a way to make this textbox disabled and still retain the value on postback?
The label is not an "input" control so values you set won't be sent to the server, the ViewState mecanism restore the value on postback. This has nothing to do with the UpdatePanel.
EDIT
If you need the value to persist you can use a Label + a HiddenField. The hidden field would make it to the server because is an "input" control and you can set the Label value on server side.
Something like this
client side
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:HiddenField ID="HiddenField1" runat="server" />
...
document.getElementById('<%= Label1.ClientID %>').innerHTML = 'test';"
document.getElementById('<%= HiddenField1.ClientID %>').value= 'test';"
server side (you execute this logic on postback)
Label1.Text = HiddenField1.Value
If you're changing a label via javascript, the server has no idea that you did that. Remember, a label is simply a span element. You do not send the entire page back to the server everytime you post back, you only send form elements. If you want the server to know about this, you'll need to put the change into a hidden form element (for example).
精彩评论