Nov 10, 2011

How to retrieve server side variables using JavaScript code



<asp:HiddenField ID="HiddenField1" runat="server" />    
public partial class LoginDemo : System.Web.UI.Page
{   
    private string str="hello";
    protected void Page_Load(object sender, EventArgs e)
    {
        HiddenField1.Value=str;
    }
}
Then you can access the control HiddenField1 using javascipt:
<script type="text/JavaScript">
Var tt=document.getElementByID(“HiddenField1”);
alert(tt.value);
</script>
  
Related posts:

0 comments:

Post a Comment

Your comments:

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More