1
votes

I have a simple aspx page.

In this page I want to add dynamically dropdownlist-textbox pairs that represent key-value pairs. But I dont know how much it is when page loading. So I must add these controls to page dynamically(in runtime)

If I add these controls in codebehind 2 problems arise :

  • Page is reloaded in every appending because of autopostback. It couses blink.
  • Whenever page reloads, previous appending disappear.

If I add these controls in client-side(javascript) :

  • Controls cannot be reachable in codebehind(because no runat=server) so validation steps open to user(I think validation steps must operate in codebehind othervise this is an integrity problem).

What would be true approach about this problem ? Could give example ?

1

1 Answers

1
votes

If you want to avoid the blink(page reload) you have to go for adding the control dynamically into your form using JavaScript.

Controls cannot be reachable in codebehind(because no runat=server)

This statement is not correct, you can always access your form control at server side using Request.Form collection. Check here for more details. You will be required to iterate over the contents of this collection to get the values.

I think validation steps must operate in codebehind othervise this is an integrity problem

Validation you need to do by yourself before performing any operation. You might required to write some custom validation logic.