ASP.NET - Page cannot be submitted after creating dynamic elements in javascript

Asked By Anandh Ramanujam on 30-Dec-10 06:17 AM
Hi,

I have created dynamic table elements in javascript.

After that, if I click submit button, page is not submitting.

And also, I cannot see the dynamically created elements thro 'Viewsource'.

What could be the cause for this...

Thanks.
Jatin Prajapati replied to Anandh Ramanujam on 30-Dec-10 06:23 AM
Dynamic created elements using javascript do not come in View Source. as this operation is performed on client site, the View source only displays the rendered source sent by Server.
Anandh Ramanujam replied to Jatin Prajapati on 30-Dec-10 06:25 AM
Ok. I understood.

But the page is not submitting...

while mouse over to the submit button, in status bar i can see the line 'javascript:;'. It happens only when I created elements dynamically.
Daivagna Nanavati replied to Anandh Ramanujam on 30-Dec-10 11:35 AM
Hi Anandh

ViewState can only be render for sever controls and you are making controls on client side and hence it cant be in viewstate, but the solution to your problem is following

if you want to submit the form you can submit it from javascript so just see the following,say you are creating button also dynamically like following

var button = document.CreateElement("input")
button.type = "submit";
button.value = "Submit"
button.click = function()
             {
              document.getElementById("form1:).submit();
             };
document.body.appendChild(button);

let me know

Thanks