loadcontrol

Discussion in 'ASP .Net' started by sunil, Aug 11, 2003.

  1. sunil

    sunil Guest

    Will the state of a dynamically loaded control preserved in transitions
    between aspx pages hosting the control.?
    thanks
     
    sunil, Aug 11, 2003
    #1
    1. Advertising

  2. sunil

    sunil Guest

    HrtgSkr, here is the situation. All web pages have header and footers which
    are user controls. Iam loading
    these controls in base class of my page using LoadControl. Will the state of
    these dynamically loaded control
    preserved between transitions in pages. For e.g Will the tree control in the
    header preserver its state when i
    navigate to a different web-pages?

    I hope iam clear now.
    Appreciate your response.
    thanks

    "HrtgSkr" <> wrote in message
    news:...
    > You want the parent page to access property values in the usercontrol?
    >
    > Create public properties in your control, then access them through the
    > usercontrol on the parent page.
    >
    > public string ControlName
    > {
    > get { return mstrName;}
    > set { mstrName = value;}
    > }
    >
    > protected MyControlClass myControl;
    >
    > string someName = myControl.ControlName;
    >
    > I have found it easier to place the usercontrol on the page, and then
    > toggle it's visible property depending on the situation.
    >
    > You probably need to create some events to allow the child to notify
    > the parent that a value has changed, and the parent to tell the child
    > to do its' job with that value.
    >
    > If the parent wants to tell the usercontrol to clear it's properties:
    >
    > public event EventHandler ClearEvent;
    >
    > protected virtual void OnClearEvent(EventArgs e)
    > {
    > if (ClearEvent != null)
    > ClearEvent(this, e);
    > }
    >
    > this.ClearEvent += new
    > System.EventHandler(this.myControl.OnClearEvent);
    >
    > In the usercontrol:
    >
    > public void OnClearEvent(object sender, System.EventArgs e)
    > {
    > mstrName = "";
    > }
    >
    > Hope that was what you meant.
    > :)
    > Dawn.
     
    sunil, Aug 12, 2003
    #2
    1. Advertising

  3. sunil

    Dawn Baker Guest

    The values in the usercontrol properties will not persist. I have
    noticed, that the webcontrols inside my usercontrol hold their viewstate
    as long as I stay on the parent page. My usercontrol isn't loaded with
    loadcontrol, though, so even though it's not visible, it's still "an
    instance".

    If you're using serialization, you can store the information you need
    from the usercontrol in ViewState. There's many ways to preserve the
    values. I've just learned through trial and error to start simple, then
    build on it, setting breakpoints and using Autos and Watch tabs to see
    the state of my variables as I move through the pages.

    Do you need to load them dynamically? Can you just modify them to
    adjust for each parent page?

    Dawn.


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Dawn Baker, Aug 13, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kurt

    Need help with LoadControl

    Kurt, Jul 1, 2003, in forum: ASP .Net
    Replies:
    5
    Views:
    441
    Natty Gur
    Jul 3, 2003
  2. huobazi
    Replies:
    1
    Views:
    711
    David Waz...
    Jul 3, 2003
  3. George Durzi

    LoadControl VirtualPath question

    George Durzi, Jul 31, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    479
    George Durzi
    Jul 31, 2003
  4. Thor W Hammer

    LoadControl performance

    Thor W Hammer, Aug 13, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    2,079
    Anders Borum
    Aug 22, 2003
  5. Replies:
    2
    Views:
    471
    Jerry III
    Nov 8, 2003
Loading...

Share This Page