Evaluate Checkboxes entered at Runtime

Discussion in 'ASP .Net' started by Michael Haberfellner, Mar 5, 2007.

  1. hi folks,

    i do have the following problem (that nearly drives me nuts :)

    1. within body-tags i call a void <% void_buildlist("lstService"); %>
    2. this void connects to a database and creates code for a selfmade-grid
    3. this is posted in the void by response.write and put on the website

    up to here everything works fine!

    now i added a checkbox for each gridline by adding this code to the text
    created in the void in front of each gridline:

    <input id=\"chkTimeDisplay" + varReader + "\" class=\"checkboxStd\"
    type=\"checkbox\" name=\"chkTimeDisplay" + varReader + "\" />

    4. this creates perfect checkboxes named chkTimeDisplay[+index] in every
    gridline

    works fine too!

    5. but now i want to evaluate all checkboxes, using for example

    foreach (Control locCtrl in this.Controls)
    {
    lblchecker.Text += locCtrl.FindControl + "; ";
    if (locCtrl is CheckBox)
    {
    ....do something
    }
    }

    and here is the problem: no result! even if i use findcontrol with the
    one correct checkboxname from the pagesource, there is no result :(

    the controls can't be found. is it because they were produced during
    runtime?

    can anybody help me out?

    thanx and nice greetings from vienna/austria

    mike
     
    Michael Haberfellner, Mar 5, 2007
    #1
    1. Advertising

  2. Michael Haberfellner

    bruce barker Guest

    if you create html controls, the page will know nothing about them. you
    should create controls or use the Request.Form collection to get values.

    -- bruce (sqlwork.com)

    Michael Haberfellner wrote:
    > hi folks,
    >
    > i do have the following problem (that nearly drives me nuts :)
    >
    > 1. within body-tags i call a void <% void_buildlist("lstService"); %>
    > 2. this void connects to a database and creates code for a selfmade-grid
    > 3. this is posted in the void by response.write and put on the website
    >
    > up to here everything works fine!
    >
    > now i added a checkbox for each gridline by adding this code to the text
    > created in the void in front of each gridline:
    >
    > <input id=\"chkTimeDisplay" + varReader + "\" class=\"checkboxStd\"
    > type=\"checkbox\" name=\"chkTimeDisplay" + varReader + "\" />
    >
    > 4. this creates perfect checkboxes named chkTimeDisplay[+index] in every
    > gridline
    >
    > works fine too!
    >
    > 5. but now i want to evaluate all checkboxes, using for example
    >
    > foreach (Control locCtrl in this.Controls)
    > {
    > lblchecker.Text += locCtrl.FindControl + "; ";
    > if (locCtrl is CheckBox)
    > {
    > ....do something
    > }
    > }
    >
    > and here is the problem: no result! even if i use findcontrol with the
    > one correct checkboxname from the pagesource, there is no result :(
    >
    > the controls can't be found. is it because they were produced during
    > runtime?
    >
    > can anybody help me out?
    >
    > thanx and nice greetings from vienna/austria
    >
    > mike
    >
    >
    >
    >
     
    bruce barker, Mar 5, 2007
    #2
    1. Advertising

  3. hi again,

    sorry for not clearly writing what i really need :)

    if i have the following in the aspx file

    <body>
    ...
    <asp:CheckBox ID="chkMe_One" runat=server/><br />
    <% void_write_checkbox(); %>
    ...
    </body>

    and in the aspx.cs file

    public void_write_checkbox()
    {
    Response.Write("<asp:CheckBox ID=\"chkMe_Two\" runat=server/>");
    }

    the second checkbox is not appearing.

    the problem is, i need to put it onto the page via response.write()

    can anybody help me please?

    big thanx

    mike

    bruce barker wrote:
    > if you create html controls, the page will know nothing about them. you
    > should create controls or use the Request.Form collection to get values.
    >
     
    Michael Haberfellner, Mar 6, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. DJ Dev
    Replies:
    7
    Views:
    710
    DJ Dev
    Feb 10, 2004
  2. TN Bella
    Replies:
    1
    Views:
    1,556
    TN Bella
    Jul 1, 2004
  3. =?Utf-8?B?TWlrZSBEcmFwZXI=?=

    Checkboxes disabled at runtime

    =?Utf-8?B?TWlrZSBEcmFwZXI=?=, Apr 28, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    374
    =?Utf-8?B?TWlrZSBEcmFwZXI=?=
    Apr 28, 2005
  4. =?Utf-8?B?TWlrZSBEcmFwZXI=?=

    Checkboxes disabled at runtime

    =?Utf-8?B?TWlrZSBEcmFwZXI=?=, Apr 28, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    396
    =?Utf-8?B?TWlrZSBEcmFwZXI=?=
    Apr 28, 2005
  5. Replies:
    28
    Views:
    12,051
    Fathzer
    Aug 29, 2012
Loading...

Share This Page