Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Access Form from WebUserControl
Message
From
13/04/2005 11:07:28
 
 
To
13/04/2005 10:52:44
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
ASP.NET
OS:
Windows XP SP1
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01003596
Message ID:
01004168
Views:
11
It's not really difficult but I'll have to review / modify my existing code which I'd like to avoid.

But if this is the least complicated way I'll take it ;-)

>>Thanks for advice Bonnie!<
>
>You're welcome, Robert. =)
>
>>Is this the only possibility???<
>
>Well, there may be other ways to do it, all probably more complicated. I think using an Interface is the more elegant approach. Why do you ask? Is this difficult for you to do?
>
>~~Bonnie
>
>
>>
>>>Robert,
>>>
>>>You could use an Interface that has the error-handler method. Form1 implements that Interface, Formxyz doesn't. Then your cal control can check that:
>>>
>>>if (oPage is IError)
>>>    ((IError) oPage).MyErrorMethod();
>>>
>>>
>>>~~Bonnie
>>>
>>>
>>>
>>>
>>>
>>>>Hi Jayesh!
>>>>
>>>>Thanks for info.
>>>>But your example will only work if I drop the ASCX onto my WebForm - if I see things right.
>>>>What if I add the ASCX dynamically?
>>>>
>>>>An example:
>>>>
  • I create "cal.ascx" which contains a calendar and is used for handling dates.
    >>>>
  • "cal.ascx" can be used on form1.aspx and also on formxy.aspx
    >>>>
  • Within "cal.ascx" I use the error-handling method which exists in form1.aspx (your code example below).
    >>>>
  • In formxy.aspx this error-handling method does not exist
    >>>>
    >>>>How can I handle this example and am I able to handle it this way?
    >>>>
    >>>>TIA
    >>>>
    >>>>>Yes. You can but not using Parent.Parent method.
    >>>>>
    >>>>>You can store the reference of the Page into a property of UserControl and then refer it to call Page methods. You will have to cast the page property to the page class in order access it's members.
    >>>>>
    >>>>>For example,
    >>>>>
    >>>>>((myCustomerPage) oPage).MyPageMethod()
    >>>>>
    >>>>>where oPage is a property in you usercontrol which stores a reference of myCustomerPage WebForm class.
    >>>>>
    >>>>>>Hi all!
    >>>>>>
    >>>>>>I'm creating several WebUserControls (ASCX).
    >>>>>>These ASCX's are later shown in my WebForms (either added dynamically or directly dropped onto them).
    >>>>>>
    >>>>>>Now my question:
    >>>>>>Is it possible to access my WebForm methods (eg: ErrorHandling methods,...) from within my ASCX?
    >>>>>>In VFP I'd say this.parent.parent.mymethod().
    >>>>>>
    >>>>>>TIA
    robert.oh.
  • Previous
    Next
    Reply
    Map
    View

    Click here to load this message in the networking platform