Resonse.Write an asp:Checkbox

  • Thread starter Thread starter Mike Haberfellner
  • Start date Start date
M

Mike Haberfellner

....hi everyone,
....i posted this allready, but my newsreader doesn't display it to me - so
i'm sorry if it's posted twice...

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
 
You can response.write a normal checkbox;

response.write ("<input type=\"checkbox\" name=\"chkMe_One\">");

Then use Request.Form or Request.Querystring to read its value.
 
but the problem with that is, that i cant access the "normal checkbox" by

foreach (Control locCtrl in this.Controls)...

or by

findcontrol("chkMe_One");

i need to go through all checkboxes and check their checked-state and name

thanx

mike
 
You are writting a server control on the client side that's why the control
does not appear.
What you could do is put a PlaceHolder <asp:PlaceHolder ID="myPlaceHolder"
runar="server" /> control where you want to display the dynamic checkbox
then on load do something like that:
CheckBox myDynamicCheckBox = new CheckBox();
myDynamicCheckBox.ID = "myCheckBoxId";
myPlaceHolder.Controls.add(myDynamicCheckBox);
HTH

Kostas Pantos
 
You may try the following

Dim chkbx As New CheckBox
chkbx.ID = "chkMe_Two"

chkbx.RenderControl(New HtmlTextWriter(Response.Output))
 
Back
Top