Reputation:
I am developing a Web Application in C#. In which the Default.aspx
page runs on startup, on that page a JavaScript is loaded(run) which creates a simple textbox and button.
Both textbox and button are created by the JavaScript.
When I click on button it gets the value from textbox. Now I want the value on Default.aspx.cs
side.
Problem:
How can I get this textbox value to the sever side (Default.aspx.cs
)
Upvotes: 0
Views: 1496
Reputation: 1410
1) If your textbox does not have runat="server" attribute, you can use the following method.
Create a hidden field which has runat="server" i.e. its a server-side control. Assign the value of this textbox to this hidden field on your button click(in javascript).
You can then access the value of the hidden field on the server-side.
2) If your textbox has runat="server" attribute, you can use the following method.
Request.Form["Name of Textbox"].ToString()
Upvotes: 1
Reputation: 28672
You can retrieve value from Request.Form
collection.
string strValue = Request.Form["Name of Control"].ToString();
Upvotes: 0
Reputation: 9499
some options:
Upvotes: 2