Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

XML
function RowSelected(sender, args) {
           
           
             document.getElementById("<%= my_label.ClientID%>").innerHTML = args.getDataKeyValue("MODULE_ID");


            


         }
Posted

Assign the value in Page_Load or window.onload Event.

Else it will always refresh as page posts back.
 
Share this answer
 
Comments
sameertm 17-Sep-13 14:33pm    
can u post sample code ?
As per your code, you are taking value from the argument (args.getDataKeyValue("MODULE_ID")).

So, how will you get this value in Page_Load()? Do you have any idea in your mind?

I think, you can store this in Session or View State, so that you will able to access it in Page_Load.

Got the idea? Please proceed.

Any questions, let me know.
sameertm 18-Sep-13 13:51pm    
can u post sample code for store value in session or viewstate. it will be great helpful for me
This is the re-bind method each time page is postback then value will be added to your label

C#
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 ...:)
 
Share this answer
 
v2
Comments
sameertm 18-Sep-13 12:15pm    
this code did not return any value
Dholakiya Ankit 18-Sep-13 23:21pm    
put your code which you have tried

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900