Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP.NET 2.0 Object creation?

Status
Not open for further replies.

passs

Programmer
Dec 29, 2003
170
RU
Hi everybody!

I'm trying to create an object dynamically. Well really not an object. The task is to put something like
<asp:Button id="btn1" runat="server"/> in form's html and make it somehow to be compiled and recognized as a web control and then rendered as a html.
This stuff I get from a XML file, which I cannot parse (because of such task:))
I tried something like
onPreInit()
{
div.InnerHTML = strHTML;
}
where strHTML has this "<asp:Button id="btn1" runat="server"/>" but I got the same asp tags in result html file.
Any ideas?
I'll be very thankfull for any help!

Thank you!
Alex
 
dim btn as new button
... set properties here...

me.controls.add(btn) 'add button to page
 
Hi,

yes that works, but my problem is different. I have a HTML code with severeal places where I should put my web controls. Parsing HTML and constructin DOM programmatically is not appropriate, so I need to take a first part of HTML before the place where web control should be put, through it to some DIV for example, then to create my web control right after this piece of html code, then to continue throughing html until I meet another flag for putting web control.
How about such situation?
I tried to create all the web controls objects and store them in an ArrayList, and then to add them to a form and render, but in this case I'm loosing a place where they should be places or get an exception that reference not set to an object...

Alex
 
You can't use the method you are currently using. You will have to use the method that Jim has suggested - if you need to place them in certain places on the web page, then use a Panel and add the control to the relevant panel.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Hi!

Thank you for your response.
Well I used another solution. I'm parsing html with some asp tags as xmls, getting all the asp tags I need to present as web controls and put all the html before each tag into HTMLGenericControl, then determine which asp control I recieve and create an object. after that I add all the object to my web form. This is not the most beautiful solution but it works:)

Thank you,
Alex
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top