Need Help with user control

  • Thread starter Thread starter WW
  • Start date Start date
W

WW

I have created a web user control and it work fine from my aspx page and I
can access its valuse from my aspx page using Run at server attribute.

BUT there are some page where I am using code behind files. The problem is
that when I try to access it from code behind files..then I get the message
that control is not declared.. Can somebody let me know how to access it
from code behind files.

Thanks in advance
 
You have to declare that control in your codebehind class.
For standard .NET controls wizard do it automatically when you drop them on
page.
For UserControls it does not do it. Just do it manually

protected clsMyControl myControl;

myControl name must match the ID you gave it in HTML.


George
 
Example.

Protected Withevents MyCalendar1 as Calander

make sure the declared name is the same as the id= in the HTML.
 

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

Back
Top