Click here to Skip to main content
15,868,419 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
public partial class Group : System.Web.UI.Page
   {
      static string strglb;

       protected void Page_Load(object sender, EventArgs e)
       {       } 



This is my Global variable 'strglb' in aspx.cs

How to set value for 'strglb' in javascript ?

please help.
Posted
Comments
saikartik 10-Aug-15 6:56am    
able to access '(<%=strglb%>)' but how to set value for it ?

1 solution

Javascript cannot access it because the variable is loaded on the server when the page is visited. What you can do is call a webservice that sets the value but that isn't likely a good way to do it either.

You can also put the value into a hidden field and then JavaScript can access the hidden field and so can C# when the page posts back.
 
Share this answer
 

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