开发者

Handling variable number of fields in ASP.NET WebForms Page

I w开发者_JAVA百科anted to gather some methods on how to add a variable number of fields to my form (with Add New and Remove buttons). I know that ASP.NET MVC has easy methods, but I'm unable to find any easy methods for WebForms.

Here's what I've used so far:

  • Adding a new UserControl to a PlaceHolder on PostBack (I've had to fiddle with ViewState to make this work correctly, huge pain)
  • Adding a new row to a grid and having a template field in a grid (works decently but kind of awkward)
  • Actually having several fields on the form by default and hiding/showing them dynamically (fairly easy but you have a set number of fields.)

Any other methods? Thanks!


You can add them with Javascript and on postback get their value with

Request.Params["ControlId_1"]

You just need a convention on the ControlId naming.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜