asp.net 2 control definition

  • Thread starter Thread starter ShayHk
  • Start date Start date
S

ShayHk

on windows form application , when I drag a button to the form...
The button declaration is created above on the code + it's properties

on Visual studio 2005 Web application
I draged a button to the page
but I cant find that button declaration in the code (only in the
html)

My question is...
How can I create buttons manualy through the code and display them on
the web page ?
 
Hi,

if you use the default web site model, adding a control on page doesn't
create a declaration for it (you don't need to have it, ASP.NET does it
automatically for you as it creates a partial class based on your aspx, so
that you have the members available automatically)

If you use VS2005 web application, it adds them into
pagename.designer.aspx.cs (or .vb) file.

Still you create controls in code by instantiating the corresponding class
and adding it to Controls collection on the Page (into the Form or
PalceHolder whatever/wherever you add it)

Button b=new Button();
PlaceHolder1.Controls.Add(b);
 
Back
Top