Web Forms

  • Thread starter Thread starter Vannela
  • Start date Start date
V

Vannela

As i asked u earlier also that is it possible to create a
web form dynamicaly and add controls to it?

For example i will write the HTML code and script code in
a single file by name Default.aspx and execute it will it
work. And when ever i want to add controls i will write
the code into same file including the events script also
will it execute it correctly.

And later if i add this .aspx page to a WEB APPLICATION
will it run correctly? Please give me the information at
the earliest

<%@Page language="vb" inherits="CodeBehindClass"
src="Default.vb" %>
<form runat="server">
<asp:button id="button1" text="button 1"
onclick="button1_click" runat="server" />
<asp:label id="lbl" text="label and button in the aspx
file " runat="server" />
</form>

<script language="C#" runat="server">
void button1_click (Object sender, EventArgs e)
{
Response.Write("hello world");
}
</script>
 
1.- Create controls at runtime? Yes, of course you can:
Button myButton = new Button();
myButton.text = "the text in the button"
myButton.Click += System.EventHander(this.myCustomHandler);
Page.Controls.Add(myButton);

Just be aware that might be considerations when dealing
with runtime created controls values in a PostBack.

2.- Create webforms at runtime?... Uhmm,i guess no but it
doesn't make sense to me. If you can post a case when that
would be necessary...

Esteban
 
No, that won't work. An html file is not an aspx file. You need more than
just an aspx extention on a file for it to be an asp.net application. What
exactly are you trying to accomplish? Maybe there is a work around.
 
Back
Top