Passing Value from Javascript to ASP.Net

19 Feb

Ref:http://forums.asp.net/p/1211504/2139016.aspx

<script type="text/javascript">
function abc()
{
  var str="value";
  document.getElementById("TextBox3").value=str;
}

</script>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
        <asp:Button ID="Button1" runat="server" OnClientClick="abc()"  Text="Button"
            onclick="Button1_Click" />
    </div>
    </form>
</body>

Code Behind:

    protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Write(TextBox3.Value.ToString);
    }
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: