Skip to content

Getting Server SideValue in Client side

Chandra Sekhar K

Asked Mar 13, 2011, 4:31 AM EDT1 answer
Share
LinkedInX
In server side I have a variable
        string s ="seversideValue";

This value i must get in clientside.How?
Is it possible through the below ways:
        1. Hidden field
        2. Eval()
and how?

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Suthish Nair
    0
    <asp:TextBox ID="HiddenField2" runat="server"></asp:TextBox>

    protected void Page_Load(object sender, EventArgs e)
        {
            string s = "seversideValue";
            if (!IsPostBack)
            {
                String ss = String.Format("document.getElementById('{0}').value = '{1}'", HiddenField2.ClientID, s);
                ClientScript.RegisterStartupScript(typeof(string), "call", ss, true);
            }           
        }


    0