asp.net label text changed at the client is not available at the web server end

放肆的年华 提交于 2019-12-24 11:46:04

问题


I am changing an asp.net label control's text using jquery at the client. But when I read it at the webserver ( C# code ), it shows me the value that was set in the UI (aspx). Is label text not a part of the control state?

Is there a way to force the label to be a part of the control state (the viewstate contains the values of the other controls like the textbox) ?


回答1:


Labels do not post their value back to the webserver. A label is basically span or label tag.

You have to either store the change in a hidden textbox as well as in the label

or

Make a textbox appear like a label in styling so the value posts back.




回答2:


Did you try EnableViewState = true for this control?

Also - IMO - the label values are not part of the posted form collection items.

Why don't you put a hidden field on the form which contains the changed text from the label & then read it on the server side?



来源:https://stackoverflow.com/questions/10324631/asp-net-label-text-changed-at-the-client-is-not-available-at-the-web-server-end

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