Hi.
I'm creating a custom webcontrol. The control should be able to recive usercontrols and place them in a "html-template". In your page you should be able to send in a usercontrol (ascx-file) and my webcontol will place it in a predefined htmltable.
Feks. (in codebehind.vb)
Dim myUserControl as Control = LoadControl("/myUserControl.ascx")
Dim a as new ns.TemplateControl()
a.title = "This is the title of the page"
a.keywords = "Keywords, key, words"
a.AddControlToRightMenu(myUserControl) 'Send control to the template
The control will generate the following html to the client:
<html>
<head>
<title>This is the title of the page</title>
<meta name="keywords" value="Keywords, key, words">
</head>
<body>
<!--myUserControl.ascx-->
<input type="text" id="txtName">
<input type="button" value="Click me!">
<!--end myUserControlascx-->
</body>
</html>
Of course this won't work without any <form> tags!
But I want to add this form tags in the webcontrol. The webcontrol use the render-method to generate the "template". And the form tag have to "runat=server". If not the usercontrols added won't work. (because the usercontrols have ex. <asp:Button>, and then : "Control '_ctl0_Button1' of type 'Button' must be placed inside a form tag with runat=server")
But i can't use this code in my webcontrol:
output.AddAttribute("runat", "server")
output.RenderBeginTag(HtmlTextWriterTag.Form)
output.RenderEndTag()
So how can i add <form runat="server"> programmatically ??
regards,
Stian