How can I get a custom made set of checkboxes return values in the postback?

Posted by AngryHacker on Stack Overflow See other posts from Stack Overflow or by AngryHacker
Published on 2010-04-02T05:09:12Z Indexed on 2010/04/02 5:13 UTC
Read the original article Hit count: 235

Filed under:
|
|
|

I have the following in an aspx page:

<td colspan="2">
    <% DisplayParties(); %>
</td>

In the code behind for the aspx page, i have this (e.g. I build HTML for the checkboxes):

public void DisplayParties() {
    var s = new StringBuilder();
    s.Append("<input type=\"checkbox\" id=\"attorney\" value=\"12345\"/>");
    s.Append("<input type=\"checkbox\" id=\"attorney\" value=\"67890\"/>");
    s.Append("<input type=\"checkbox\" id=\"adjuster\" value=\"125\"/>");
    Response.WriteLine(s.ToString());
}

Not my proudest moment, but whatever. The problem is that when this page posts back via some event on the page, I never get these tags in the Request.Form collection.

Is this simply how ASP.NET works (e.g. only server-side control post back) or am I missing something simple.

My understanding was that a postback should bring back all the form variables.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about vs2008