You cannot create a βrealβ runat = server element / control without doing a full postback to the server.
A better approach would be to write some script that stores innerHTML in a hidden ASP.Net field right before the page is submitted. You can then access the value of this hidden field to capture data.
If you want to dynamically create multiple objects, you need to use the standard html hidden input fields, since you cannot create asp.net server controls through javascript.
<input type="hidden" name="fieldData_1" value="control 1 html content"> <input type="hidden" name="fieldData_2" value="control 2 html content">
Then you can access these hidden fields from the Request.Form object:
Request.Form["fieldData_1"]
Knowing this, you can now iterate over form data and process all your dynamic fields
foreach (string fieldData in Request.Form) { if(fieldData.Contains("fieldData_"){
You can also avoid using hidden fields and simply transfer your data to the server directly using the __doPostback ('', '') method. It can be implemented in different ways, so I just refer you to http://dopostback.net to read how this method works.
source share