Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

.NET 2.0 - User control + events

Status
Not open for further replies.

RhythmAddict112

Programmer
Jun 17, 2004
625
US
Hello . I've got a user created custom control with 4 drop down lists and a button. This control is on my main page, default3.aspx. What I'd like to do is fire an event on the main page (default3.aspx) when the button is clicked on the user control (DropMenu.ascx) This is what I've tried...

Code:
 private void InitializeComponent()
        {
//Menu1 = my control, Button1 = the ID of the button within the control            
Menu1.Button1.Click += new System.EventHandler(evalDdls);

The error I get is "'Menu1.Button1' is inaccessible due to its protection level" The tricky thing is, in 2003 I would see my controls declared as such within my code

Code:
protected System.Web.Ui.WebControls.Button button1;

And thus, I could modify the protection level (make it public) In 2k5, there are no viewable control declartions...How do I solve this? Thanks!

 
I believe that there are viewable control declarations, but I can not figure out how to reveal them. I'll keep trying, but hopefully someone else will chime in here. Need to reveal the partial class (called something like default.designer.cs)
 
In the solution explorer look for a button that says "Show All Files" I'm using Visual Web Developer so it might be limited because I can't find it. Also I found this...

"If you want, you can also optionally declare your controls manually within your code-behind file (for example: if you wanted to add a custom attribute to them or define a custom type to use). If VS detects that a control declaration has already been made in the code-behind file by you, then it will automatically omit duplicating it from the .designer.cs/.vb file (which is a nice, useful feature)."


And this might be helpful.
 
JShurst,
Thank you for your the time you have spent on this - it is greatly appreciated. I'm going to compile all the information I've found on this seemingly evasive subject and post the direct link to my blog entry on it ASAP...Thanks again!
-Sanjay

 
No problem. I was wondering that myself and I knew that I'd ran accross it before. I haven't moved to VS2005 yet (at work) so I haven't jumped in fully yet, but trying to pick up some things as I move there. Good luck.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top