I am trying to get value of Javascript variable on server side, but it always shows values on second button click and I don't want to reload this page again

    protected void Button1_Click(object sender, EventArgs e)
    {

        Page.ClientScript.RegisterStartupScript(Page.GetType(), "MessageBox", "<script language='javascript'>setValues();</script>");
        Thread.Sleep(5000);
        Response.Write(HiddenField1.Value);
    }

Javascript Code . . . ..

<script type="text/javascript">

    function setValues()
    {
        var abc = "thi is first";
        document.getElementById('<%=HiddenField1.ClientID%>').value = abc;
    }

</script>

Related posts

Recent Viewed