views:

39

answers:

2

I am creating some dynamic textboxes through javascript, when postback is happening i am loosing the controls. I can't use Ajax instead of postback and i can't create dynamic controls from code behind.

Can anyone please give any suggestion about it?

A: 

If you create controls on client in javascript they will not be created for you on server side because server side doesn't know about them. If you want data posted from these controls you can access them by Request.Form collection.

Ladislav Mrnka
Can you please provide some code for accessing the controls using Request.Form collection?
Dev
A: 

Can you not just create the textboxes server side, and show/hide via javascript/CSS? This prevents javascript doing any creating of controls and concentrates on the correct displaying of the user interface. The server knows all the controls on the page, and can deal with the business logic appropriately.

m.edmondson
But the number of textbox controls are not fixed. There is a textbox which takes the number of textboxes that should be created and by javascript i am creating the number of textboxes requested.
Dev
In that case I would probably put everything into an UpdatePanel so that the server is still 'aware' of the input boxes to which it will receive some user input, otherwise you might run into problems.
m.edmondson
You can perform the same function in code behind. You don't need to do it in javascript.
TheGeekYouNeed
Yes i can do it in server side also but doing it in javascript is much faster, that's why i am going by Javascript approach.
Dev
@Dev - I would very much like to see if you come up with a solution but I think asp.net will have problems with this.
m.edmondson