Hi,
In Asp.net,any server side control,you will find runat=”server” ,right?
now suppose. you are adding html control dynamically from javascript and you have written code like this.
var count=0;
function AddTextBox()
{
var Td= document.getElementById(’ctl00_ContentPlaceHolder1_tdDegreeContainer’);
var newText = document.createElement(’Input’);
newText.type=”text”;
var temp_name= “text”+count.toString();
newText.setAttribute(’id’,temp_name.toString());
var temp_value=”Degree”+count.toString();
newText.setAttribute(’value’,temp_value.toString());
newText.setAttribute(’runat’,’server’);
Td.appendChild(newText);
}
count++;
}
i have written this code for adding “Educational Qualification(degree)” of the member.
Basically, this code will add html text box dynamically into the ”td” control of the html/asp.net table.
try to complie above code… you will get following error.
“unformatted Server tag”
means,you can not add runat=”server” from javascript.
Then,What is the Alternative??
step1> Create hidden html field(s) and add runat=”server” statically.
step2> Create one Sync() javascript function. which will assign the values of dynamically generated text box to the hidden field .
step3> B’coz of runat=”server” in hidden fileld. you can access it from code behind.



