Get the UserControl on which a Control resides?

  • Thread starter Thread starter Steve - DND
  • Start date Start date
S

Steve - DND

I have a custom validation control I have created. One of the actions it
performs is similar to the CustomValidator in that I specify a function to
run, and it goes and runs the function. Previously I had been doing this
with the line:

this.VerifyValidate +=
(VerifyValidateDelegate)Delegate.CreateDelegate(typeof(VerifyValidateDelegat
e), this.Page, m_CustomFunction);

This has worked fine as long as the control resided on an ASPX page. Today I
tried using the control for the first time on an ASCX page that I made, and
found out that it won't work. I have figured out that the problem is that
with this.Page specified, the CreateDelegate function is looking for the
function I specified on the ASPX page, when I really need it to find the
function on the ASCX page.

So my question is, how can I determine the actual place on which a control
resides? I looked through the various properties of the System.Web.UI.Page
and was unable to find any property that would tell me immediately where a
control resides. Any insight would be appreciated.

Thanks,
Steve
 
Steve - DND said:
I have a custom validation control I have created. One of the actions it
performs is similar to the CustomValidator in that I specify a function to
run, and it goes and runs the function. Previously I had been doing this
with the line:

this.VerifyValidate +=
(VerifyValidateDelegate)Delegate.CreateDelegate(typeof(VerifyValidateDelegat
e), this.Page, m_CustomFunction);

This has worked fine as long as the control resided on an ASPX page. Today I
tried using the control for the first time on an ASCX page that I made, and
found out that it won't work. I have figured out that the problem is that
with this.Page specified, the CreateDelegate function is looking for the
function I specified on the ASPX page, when I really need it to find the
function on the ASCX page.

So my question is, how can I determine the actual place on which a control
resides? I looked through the various properties of the System.Web.UI.Page
and was unable to find any property that would tell me immediately where a
control resides. Any insight would be appreciated.

Oops... In my haste to post to this group I completely overlooked the
NamingContainer property of my validation control. I was able to put
this.NamingContainer in place of this.Page and now everything works
perfectly.

Steve
 
Back
Top