asp.net标签值在回发中的变化 [英] asp.net label value change in postback
本文介绍了asp.net标签值在回发中的变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨所有
i有网络应用程序,在我的网络应用程序中我习惯使用javascript获取数据并分配该值
到asp.net标签控件。但当页面回发标签值重置时。
我如何在我的asp.net标签控件中保留该值
<下面是
是我的javascript代码
hi all
i have web application, in my web application i used to get data using javascript and assign that value
to asp.net label control. but when the page postback the label value is getting reset.
how shall i persist the value in my asp.net label control
below is my javascript code
function RowSelected(sender, args) {
document.getElementById("<%= my_label.ClientID%>").innerHTML = args.getDataKeyValue("MODULE_ID");
}
推荐答案
分配Page_Load
或中的值window.onload
事件。
否则它将始终刷新为页面回发。
Assign the value inPage_Load
orwindow.onload
Event.
Else it will always refresh as page posts back.
这是重新绑定方法,每次页面回发时,值将被添加到您的标签
This is the re-bind method each time page is postback then value will be added to your label
string sb1 = "function RowSelected(sender, args) {document.getElementById('<%= my_label.ClientID%>').innerHTML = args.getDataKeyValue('MODULE_ID');}";
ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "script", sb1, true);
如果你把这段代码放在你的页面加载你正在使用的回传方法那么它将起作用... :)
if you put this code in your page load what ever postback method you are using then it will work ...:)
这篇关于asp.net标签值在回发中的变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文