asp.net 2005, LoadControl question...

A

Andrew Taylor

I have created a user control (ascx) called MyButton with a code
behind file.

I also have a main page (aspx) with a code behind file.

I want to do something like this in the main page


void Page_Load(object sender, EventArgs e)
{
MyButton button = new MyButton();
// or MyButton button = LoadControl("MyButton.ascx");
button.Text = "HI";
placeHolder.Controls.Add(button);
}

Button the MyButton class does not show up with intellisense. Since
there is not build command anymore for web projects, is it because it
is not build ? Could it be namespace related, it seems all namespace
entries are gone as well ?

-- Thanks, Andrew Taylor
 
N

Natty Gur

Hi,

1) regarding namespace: if you working with "place code with separate
file" you will see Namespace. Otherwise namespace declared in the class
create for page in page compilation phase.

2) due to the fact that that every page might end up with dedicate
assembly (not as ASP.NET 1.X that all pages code behinds compile to same
DLL) you need to use <@ reference .. %> Directive in order to get
UserControl intellisense ...

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)52-8888377


*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top