User control event problem

R

Rob Morgan

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?
 
K

Kevin Spencer

Page.MethodName()

--
HTH,

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

S. Justin Gengo

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
 
R

Rob Morgan

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.
 
K

Kevin Spencer

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
 

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,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top