What I was attempting to do was create an input box using javascript, fill it with details and post it back to the server.
Code to create the input box and place it in a div:
function addtb()
{
var getdiv = document.getElementById('holddiv');
getdiv.innerHTML = getdiv.innerHTML + "";
count++;
}
On the code behind though, rather than accessing it using the id/name directly (you cannot do something like [input-box-id].Text = ’some text’) you have to get its value from the Request variable and use the data.
string c = Request.Form["tbs"].ToString();
Also if you wanted it to get displayed on the page the next time around you would have to recreate the elements manually in c#
TextBox t = new TextBox();
t.ID = f;
t.Attributes.Add("name", "tbs");
t.Text = f;
Page.Form.Controls.Add(t);
Although this is cumbersom, it works. I’m not sure if there is an easier way to accomplish this.
No comments:
Post a Comment