User control event problem

Discussion in 'ASP .Net' started by Rob Morgan, Nov 12, 2005.

  1. Rob Morgan

    Rob Morgan Guest

    I have a grid and a user control on the same page. The user control has a
    save button that triggers a click event server side. Once the click event
    happens the page renders, but I need to update the grid information before
    it renders. Once a conrol's event finishes is there a way to run a method
    on the parent page so I can update the gid? Any thoughs on how I might
    accomplish this?
    Rob Morgan, Nov 12, 2005
    #1
    1. Advertising

  2. Page.MethodName()

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    Complex things are made up of
    Lots of simple things.

    "Rob Morgan" <> wrote in message
    news:...
    >I have a grid and a user control on the same page. The user control has a
    > save button that triggers a click event server side. Once the click event
    > happens the page renders, but I need to update the grid information before
    > it renders. Once a conrol's event finishes is there a way to run a method
    > on the parent page so I can update the gid? Any thoughs on how I might
    > accomplish this?
    >
    >
    Kevin Spencer, Nov 12, 2005
    #2
    1. Advertising

  3. Rob,

    If you want the event to run on the main page only when that button is
    clicked you may find out when a button is clicked by overriding the
    OnBubbleEvent on the main page like this:

    1.. Protected Overrides Function OnBubbleEvent(ByVal source As Object,
    ByVal args As System.EventArgs) As Boolean
    2.. Try
    3.. Select Case (source.GetType.ToString)
    4.. Case "System.Web.UI.WebControls.Button"
    5.. Dim Button As Button
    6..
    7.. Button = CType(source, System.Web.UI.WebControls.Button)
    8..
    9.. Select Case Button.ID
    10.. Case "SubmitButton"
    11.. '---Call any code you want here: with access to the control's
    viewstate.
    12..
    13.. Case "CancelButton"
    14.. End Select
    15.. Case "System.Web.UI.WebControls.LinkButton"
    16.. Dim LinkButton As LinkButton
    17..
    18.. LinkButton = CType(source, System.Web.UI.WebControls.LinkButton)
    19..
    20.. Select Case LinkButton.ID
    21.. Case "HomeLinkButton", "SortLinkButton"
    22.. End Select
    23.. End Select
    24.. Catch ex As Exception
    25.. '---Process Exception
    26.. End Try
    27.. End Function

    --
    Sincerely,

    S. Justin Gengo, MCP
    Web Developer / Programmer

    www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzsche
    "Rob Morgan" <> wrote in message
    news:...
    >I have a grid and a user control on the same page. The user control has a
    > save button that triggers a click event server side. Once the click event
    > happens the page renders, but I need to update the grid information before
    > it renders. Once a conrol's event finishes is there a way to run a method
    > on the parent page so I can update the gid? Any thoughs on how I might
    > accomplish this?
    >
    >
    S. Justin Gengo, Nov 12, 2005
    #3
  4. Rob Morgan

    Rob Morgan Guest

    My methods don't seem to be in Page or am I mising something simple?

    "Kevin Spencer" <> wrote in message
    news:#...
    > Page.MethodName()
    >
    > --
    > HTH,
    >
    > Kevin Spencer
    > Microsoft MVP
    > .Net Developer
    > Complex things are made up of
    > Lots of simple things.
    >
    > "Rob Morgan" <> wrote in message
    > news:...
    > >I have a grid and a user control on the same page. The user control has

    a
    > > save button that triggers a click event server side. Once the click

    event
    > > happens the page renders, but I need to update the grid information

    before
    > > it renders. Once a conrol's event finishes is there a way to run a

    method
    > > on the parent page so I can update the gid? Any thoughs on how I might
    > > accomplish this?
    > >
    > >

    >
    >
    Rob Morgan, Nov 12, 2005
    #4
  5. Rob Morgan

    Rob Morgan Guest

    Thanks for the example.... My example was a bit simplified because I'm
    dynamically loading the controls and the controls could have anything within
    them. The last thing the control should after it runs any events is to tell
    the page to update itself so it can show the last modifications from the
    controls event. The best wqy, that I know, is to have every control call a
    standard method from the parent page that pulls the latest data and then
    render.

    "S. Justin Gengo" <justin@[no_spam_please]aboutfortunate.com> wrote in
    message news:...
    > Rob,
    >
    > If you want the event to run on the main page only when that button is
    > clicked you may find out when a button is clicked by overriding the
    > OnBubbleEvent on the main page like this:
    >
    > 1.. Protected Overrides Function OnBubbleEvent(ByVal source As Object,
    > ByVal args As System.EventArgs) As Boolean
    > 2.. Try
    > 3.. Select Case (source.GetType.ToString)
    > 4.. Case "System.Web.UI.WebControls.Button"
    > 5.. Dim Button As Button
    > 6..
    > 7.. Button = CType(source, System.Web.UI.WebControls.Button)
    > 8..
    > 9.. Select Case Button.ID
    > 10.. Case "SubmitButton"
    > 11.. '---Call any code you want here: with access to the control's
    > viewstate.
    > 12..
    > 13.. Case "CancelButton"
    > 14.. End Select
    > 15.. Case "System.Web.UI.WebControls.LinkButton"
    > 16.. Dim LinkButton As LinkButton
    > 17..
    > 18.. LinkButton = CType(source, System.Web.UI.WebControls.LinkButton)
    > 19..
    > 20.. Select Case LinkButton.ID
    > 21.. Case "HomeLinkButton", "SortLinkButton"
    > 22.. End Select
    > 23.. End Select
    > 24.. Catch ex As Exception
    > 25.. '---Process Exception
    > 26.. End Try
    > 27.. End Function
    >
    > --
    > Sincerely,
    >
    > S. Justin Gengo, MCP
    > Web Developer / Programmer
    >
    > www.aboutfortunate.com
    >
    > "Out of chaos comes order."
    > Nietzsche
    > "Rob Morgan" <> wrote in message
    > news:...
    > >I have a grid and a user control on the same page. The user control has

    a
    > > save button that triggers a click event server side. Once the click

    event
    > > happens the page renders, but I need to update the grid information

    before
    > > it renders. Once a conrol's event finishes is there a way to run a

    method
    > > on the parent page so I can update the gid? Any thoughs on how I might
    > > accomplish this?
    > >
    > >

    >
    >
    Rob Morgan, Nov 12, 2005
    #5
  6. Hi Rob,

    Every Control has a member called "Page" which is a reference to the Page it
    is run in.

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    There's a seeker born every minute.
    - Dr. "Happy" Harry Cox

    "Rob Morgan" <> wrote in message
    news:...
    > My methods don't seem to be in Page or am I mising something simple?
    >
    > "Kevin Spencer" <> wrote in message
    > news:#...
    >> Page.MethodName()
    >>
    >> --
    >> HTH,
    >>
    >> Kevin Spencer
    >> Microsoft MVP
    >> .Net Developer
    >> Complex things are made up of
    >> Lots of simple things.
    >>
    >> "Rob Morgan" <> wrote in message
    >> news:...
    >> >I have a grid and a user control on the same page. The user control has

    > a
    >> > save button that triggers a click event server side. Once the click

    > event
    >> > happens the page renders, but I need to update the grid information

    > before
    >> > it renders. Once a conrol's event finishes is there a way to run a

    > method
    >> > on the parent page so I can update the gid? Any thoughs on how I might
    >> > accomplish this?
    >> >
    >> >

    >>
    >>

    >
    >
    Kevin Spencer, Nov 12, 2005
    #6
  7. Rob,

    In that case Kevin's example is perfect for your needs.

    --
    Sincerely,

    S. Justin Gengo, MCP
    Web Developer / Programmer

    www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzsche
    "Rob Morgan" <> wrote in message
    news:uAJj$...
    > Thanks for the example.... My example was a bit simplified because I'm
    > dynamically loading the controls and the controls could have anything
    > within
    > them. The last thing the control should after it runs any events is to
    > tell
    > the page to update itself so it can show the last modifications from the
    > controls event. The best wqy, that I know, is to have every control call
    > a
    > standard method from the parent page that pulls the latest data and then
    > render.
    >
    > "S. Justin Gengo" <justin@[no_spam_please]aboutfortunate.com> wrote in
    > message news:...
    >> Rob,
    >>
    >> If you want the event to run on the main page only when that button is
    >> clicked you may find out when a button is clicked by overriding the
    >> OnBubbleEvent on the main page like this:
    >>
    >> 1.. Protected Overrides Function OnBubbleEvent(ByVal source As Object,
    >> ByVal args As System.EventArgs) As Boolean
    >> 2.. Try
    >> 3.. Select Case (source.GetType.ToString)
    >> 4.. Case "System.Web.UI.WebControls.Button"
    >> 5.. Dim Button As Button
    >> 6..
    >> 7.. Button = CType(source, System.Web.UI.WebControls.Button)
    >> 8..
    >> 9.. Select Case Button.ID
    >> 10.. Case "SubmitButton"
    >> 11.. '---Call any code you want here: with access to the control's
    >> viewstate.
    >> 12..
    >> 13.. Case "CancelButton"
    >> 14.. End Select
    >> 15.. Case "System.Web.UI.WebControls.LinkButton"
    >> 16.. Dim LinkButton As LinkButton
    >> 17..
    >> 18.. LinkButton = CType(source, System.Web.UI.WebControls.LinkButton)
    >> 19..
    >> 20.. Select Case LinkButton.ID
    >> 21.. Case "HomeLinkButton", "SortLinkButton"
    >> 22.. End Select
    >> 23.. End Select
    >> 24.. Catch ex As Exception
    >> 25.. '---Process Exception
    >> 26.. End Try
    >> 27.. End Function
    >>
    >> --
    >> Sincerely,
    >>
    >> S. Justin Gengo, MCP
    >> Web Developer / Programmer
    >>
    >> www.aboutfortunate.com
    >>
    >> "Out of chaos comes order."
    >> Nietzsche
    >> "Rob Morgan" <> wrote in message
    >> news:...
    >> >I have a grid and a user control on the same page. The user control has

    > a
    >> > save button that triggers a click event server side. Once the click

    > event
    >> > happens the page renders, but I need to update the grid information

    > before
    >> > it renders. Once a conrol's event finishes is there a way to run a

    > method
    >> > on the parent page so I can update the gid? Any thoughs on how I might
    >> > accomplish this?
    >> >
    >> >

    >>
    >>

    >
    >
    S. Justin Gengo, Nov 13, 2005
    #7
    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. vatech1993
    Replies:
    4
    Views:
    5,675
    =?Utf-8?B?U8Opcmdpbw==?=
    Dec 11, 2004
  2. Don
    Replies:
    3
    Views:
    5,434
    Karl Seguin
    Mar 11, 2005
  3. Mad Scientist Jr
    Replies:
    0
    Views:
    627
    Mad Scientist Jr
    Mar 22, 2006
  4. Jonathan Wood

    User Control to Control Other User Control

    Jonathan Wood, Jan 24, 2010, in forum: ASP .Net
    Replies:
    4
    Views:
    533
    Jonathan Wood
    Feb 2, 2010
  5. Fabrizio
    Replies:
    5
    Views:
    221
    Alessandro Zifiglio
    Feb 24, 2004
Loading...

Share This Page