Hey there folks, I have a user control (UCInside, e.g.) inside another user control (UCOutside). I want to call a function that's contained in UCInside from UCOutside. Since UCInside has an associated class (let's call it ClassInside), I figured I could call
the function by a simple
ClassInside.UCInside.MyFunction(params)
This calls the function, but I then can't seem to access any of web controls in UCInside from that function.
Specifically, I have a RadioButtonList defined in UCInside. I want to retrieve, and then use, the selectedValue in MyFunction. I get an 'object reference not set to instance of object' error on
strMyValue= Me.radiobuttonlist1.SelectedValue
Can I not call the function from the outside user control? Since UCInside is in UCOutside, it won't help to raise an event, right? Thanks, Rachel
Thanks guys, I got it. I CAN call another user control's function from a user control containing that one. The confusion came because I had programmatically added my user control (as follows):
When this threw errors at me, I declared and instantiated a second copy of the inside user control, and called that version's function. I should have just used the version of the control I already had on the page, and typecast it.
rachelreese
Member
130 Points
26 Posts
ASPInsiders
User Control calling function in another user control?
Aug 06, 2003 07:18 PM|LINK
rachelreese
Member
130 Points
26 Posts
ASPInsiders
Re: User Control calling function in another user control?
Aug 07, 2003 01:36 AM|LINK
MyPlaceHolder.Controls.Add(LoadControl("UCInside.ascx"))So, I couldn't just sayWhen this threw errors at me, I declared and instantiated a second copy of the inside user control, and called that version's function. I should have just used the version of the control I already had on the page, and typecast it. -Rachel