control at runtime

modularbeing

Regular
Joined
Jan 8, 2004
Messages
63
I am pulling some html from a webservice and adding it to my aspx page, but I need to add a checkbox control into that html I have pulled down. Is there a way I can add a web control to the html before I write it out to the page?
 
this.Controls.Add( .......)

try this.

You can make it in the Page_Load so it load before everything else.

You can add any control this way.
 
Arch4ngel said:
this.Controls.Add( .......)

try this.

You can make it in the Page_Load so it load before everything else.

You can add any control this way.

This will not work if I do controls.add(objControl). in the Page_Load event I am grabbing html from an external source and I need to insert a control into that html. So right now I am getting the html from the source and then doing a response.write() to put the html on my aspx page. I would like to use webcontrols for this to make programming easier but I might have to use html controls and then post back to the aspx page to get the values. If there is a way around this so that I can use web controls in this Im open to any ideas.

Thanks
 
Here it is

Put this at the beginning of your aspx file. (not the .aspx.cs)
It will load the file you want.

<%
Server.Execute(@"File.htm");
%>
 
I would like to stay away from dumping the contents to a file and then reading it back into the page just because of the latency of I/O. I think I am going to try making a user control and see if it will render the check box tags when I add that to the page. I'll see what happens, I have to read more into making a user control first since I have never made one before.....
 
I did some more looking and I found that If I parse the html into variables, One being the html before the control location and the second being the html after the control location, then create the checkbox control. Then use literalcontrol to post the html to the page and then controls.add(checkbox). this is the code I used:
Code:
         MyBase.Controls.Add(New LiteralControl(LiteralControl(0)))
         MyBase.Controls.Add(chkSignature(0))
         MyBase.Controls.Add(New LiteralControl(LiteralControl(1)))

LiteralControl(0) is the first part of the html and literalcontrol(1) is the second part. I put all this into a usercontrol and I call that on the page.
 
Back
Top