Ask a Question related to ASP.NET General, Design and Development.
-
Steve C. Orr, MCSD #1
Re: How to intercept an event in ASP.NET?
You can override the RaisePostBackEvent method of the Page class.
The first parameter sent to this method is the object that caused the
postback.
Remember to call MyBase.RaisePostBackEvent so the postback event gets raised
correctly.
Alternately, instead of the load event you could move your conditional code
to the PreRender event , which happens after all the control events. So by
then you'll know which control(s) caused the postback.
--
I hope this helps,
Steve C. Orr, MCSD
[url]http://Steve.Orr.net[/url]
"Jon" <to_jon@hotmail.com> wrote in message
news:e4b2505c.0308051326.4170a95e@posting.google.c om...> I'm new to event handling in ASP.NET and would like to intercept an
> event in the standard Page_Load routine. Basically, I'd like to know
> what user event trigerred the page load- the name of the button
> pressed or other object involved. I know that the Page_Load sub is
> passed 2 things: System.Object and System.EventArgs. Can I access
> one of these to get the info?
>
> Is this possible... I also realize that I may be thinking of this the
> wrong way conceptually.
>
> Thanks
> Jon
Steve C. Orr, MCSD Guest
-
How to intercept property changes in subclassed control?
I've got an application that uses constants stored in XML files (see attached). The XML files are loaded into mx:Models and used as dataProviders on... -
Intercept when my control dropped on a WebForm
Hi All! I need to intercept the event when my control dropped on a WebForm (or manually added by changin page's source HTML). I know about... -
HttpWebResponse intercept raw HTTP?
For diagnostic and learning purposes, I would like to intercept and log the raw HTTP headers and content from a HttpWebResponse in a webservice. ... -
Usercontrol Postback - can i intercept Request
Hi I have a site that creates a template file "default.aspx" and places usercontrols in it to display the pages. The beginrequest event redirects... -
WEBFORM: can I intercept Back and...
Roby, HTTP is connectionless. Therefore, you have no way of intercepting client-side events from server-side code. Jim Cheshire Developer... -
MS News #2
Re: How to intercept an event in ASP.NET?
Goto your CodeFront/Presentation Page ( Design Mode ) of your web page
Double Click on the Button you want. This will take you to the CodeBehind
page
Type in your Button Handler Code
private void Button1_Click(object sender, System.EventArgs e)
{
// type here what you want
}
"Jon" <to_jon@hotmail.com> wrote in message
news:e4b2505c.0308051326.4170a95e@posting.google.c om...> I'm new to event handling in ASP.NET and would like to intercept an
> event in the standard Page_Load routine. Basically, I'd like to know
> what user event trigerred the page load- the name of the button
> pressed or other object involved. I know that the Page_Load sub is
> passed 2 things: System.Object and System.EventArgs. Can I access
> one of these to get the info?
>
> Is this possible... I also realize that I may be thinking of this the
> wrong way conceptually.
>
> Thanks
> Jon
MS News Guest
-
John Saunders #3
Re: How to intercept an event in ASP.NET?
Why not simply handle the event raised by the object which caused the
postback? For instance, the Click event of a button, or SelectedIndexChanged
of a DropDownList?
--
John Saunders
Internet Engineer
[email]john.saunders@surfcontrol.com[/email]
"Jon" <to_jon@hotmail.com> wrote in message
news:e4b2505c.0308051326.4170a95e@posting.google.c om...> I'm new to event handling in ASP.NET and would like to intercept an
> event in the standard Page_Load routine. Basically, I'd like to know
> what user event trigerred the page load- the name of the button
> pressed or other object involved. I know that the Page_Load sub is
> passed 2 things: System.Object and System.EventArgs. Can I access
> one of these to get the info?
>
> Is this possible... I also realize that I may be thinking of this the
> wrong way conceptually.
>
> Thanks
> Jon
John Saunders Guest
-
Jon #4
Re: How to intercept an event in ASP.NET?
That's a good point John- in short, I'd like to do something if the
form has been posted through ALL types of events except for one or two
specific events. It seems easier to detect that in the Page_Load
rather than add code to every possible event for every object on the
page. Hope that's more clear.
"John Saunders" <john.saunders@surfcontrol.com> wrote in message news:<OJiuU35WDHA.1644@TK2MSFTNGP10.phx.gbl>...> Why not simply handle the event raised by the object which caused the
> postback? For instance, the Click event of a button, or SelectedIndexChanged
> of a DropDownList?
>
> --
> John Saunders
> Internet Engineer
> [email]john.saunders@surfcontrol.com[/email]
>
>
> "Jon" <to_jon@hotmail.com> wrote in message
> news:e4b2505c.0308051326.4170a95e@posting.google.c om...> > I'm new to event handling in ASP.NET and would like to intercept an
> > event in the standard Page_Load routine. Basically, I'd like to know
> > what user event trigerred the page load- the name of the button
> > pressed or other object involved. I know that the Page_Load sub is
> > passed 2 things: System.Object and System.EventArgs. Can I access
> > one of these to get the info?
> >
> > Is this possible... I also realize that I may be thinking of this the
> > wrong way conceptually.
> >
> > Thanks
> > JonJon Guest
-
John Saunders #5
Re: How to intercept an event in ASP.NET?
"Jon" <to_jon@hotmail.com> wrote in message
news:e4b2505c.0308061153.754eb3ed@posting.google.c om...It's clearer.> That's a good point John- in short, I'd like to do something if the
> form has been posted through ALL types of events except for one or two
> specific events. It seems easier to detect that in the Page_Load
> rather than add code to every possible event for every object on the
> page. Hope that's more clear.
I would put that common code in a subroutine and call it from the handler of
each event where you want that common stuff done. You should not have any
one part of your code whose job it is to know about all the possible events
your form may generate now or in the future. What if form changes
substantially? Instead, for each event, handle that event and do what's
appropriate because of the event having taken place.
If you wind up with common code amongst the event handlers, yank it out into
a subroutine. For instance, I commonly need to display an error message in a
status label. I yanked that out into a SetStatus subroutine. I call it from
many separate events.
--
John Saunders
Internet Engineer
[email]john.saunders@surfcontrol.com[/email]
John Saunders Guest



Reply With Quote

