Get the UserControl on which a Control resides?

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
 
S

Steve - DND

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
 

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