Is there a way to detect the cause of a postback?

P

Paul

I'd like to set a DataView on a DataGrid during Page_Load() but only if
the page is loading because of it being hit by a response.redirect from
another page. Is there any way to detect what entity causes a postback?

Page_Load() itself offers very little because sender is always an entity
on the page. Eventargs didn't seem to be much help.

I'm thinking of setting a session var in the button click event of the
page that causes the response.redirect. I guess that would work, but
what do you think? I could use that var to do a conditional check.


~Paul
 
G

Guest

Session, or could use a querystring. I also saw somebody refer to "http referrer", which I took to be what you're looking for, but I've not found any more info on that. Hopefully somebody else will weigh in

----- Paul wrote: ----

I'd like to set a DataView on a DataGrid during Page_Load() but only i
the page is loading because of it being hit by a response.redirect fro
another page. Is there any way to detect what entity causes a postback

Page_Load() itself offers very little because sender is always an entit
on the page. Eventargs didn't seem to be much help.

I'm thinking of setting a session var in the button click event of th
page that causes the response.redirect. I guess that would work, bu
what do you think? I could use that var to do a conditional check


~Pau

*** Sent via Developersdex http://www.developersdex.com **
Don't just participate in USENET...get rewarded for it
 
M

matt

You could just check the value of http referrer as below

if(Request.ServerVariables["HTTP_REFERER"].ToString() ==
http://www.mydomain.co.uk/mypage.aspx) {
// include required code to set DataView on a datagrid.....
}

The referrer will include the querystring of the page that your user was
redirect from so bear this in mind, you may find you need to check for the
indexOf your page name or something other than a simple equals comparison.

Hope that helps.

Matt
http://www.3internet.com
Inigo Content Management System - c#, asp.net, xml cms



Bill Borg said:
Session, or could use a querystring. I also saw somebody refer to "http
referrer", which I took to be what you're looking for, but I've not found
any more info on that. Hopefully somebody else will weigh in.
 
G

Guest

I've been playing with HTTP_REFERER. This is going to come in *very* handy. Thanks

----- matt wrote: ----

You could just check the value of http referrer as belo

if(Request.ServerVariables["HTTP_REFERER"].ToString() =
http://www.mydomain.co.uk/mypage.aspx)
// include required code to set DataView on a datagrid....


The referrer will include the querystring of the page that your user wa
redirect from so bear this in mind, you may find you need to check for th
indexOf your page name or something other than a simple equals comparison

Hope that helps

Mat
http://www.3internet.co
Inigo Content Management System - c#, asp.net, xml cm



Bill Borg said:
Session, or could use a querystring. I also saw somebody refer to "htt
referrer", which I took to be what you're looking for, but I've not foun
any more info on that. Hopefully somebody else will weigh in
 
P

Paul

Bill, have you checked out the request.URLreferer object? Very cool.
It can segment each part of the path in a URL and it leaves the final
segment as the file name. The segments are in an array so you can get
the length minus one and use that segment to determine the sending page
name.

Dim y As Integer

Dim arrLength As Integer= Request.UrlReferrer.Segments.Length

y = (arrLength - 1)

Dim filename As String = Request.UrlReferrer.Segments(y)




~Paul
 
G

Guest

P.S. I just ran across httprequest.urlreferrer (two r's, this time). I presume it just wraps the server variable, but might be a little safer, and in my quick tests the two always return the same thing

----- matt wrote: ----

You could just check the value of http referrer as belo

if(Request.ServerVariables["HTTP_REFERER"].ToString() =
http://www.mydomain.co.uk/mypage.aspx)
// include required code to set DataView on a datagrid....


The referrer will include the querystring of the page that your user wa
redirect from so bear this in mind, you may find you need to check for th
indexOf your page name or something other than a simple equals comparison

Hope that helps

Mat
http://www.3internet.co
Inigo Content Management System - c#, asp.net, xml cm



Bill Borg said:
Session, or could use a querystring. I also saw somebody refer to "htt
referrer", which I took to be what you're looking for, but I've not foun
any more info on that. Hopefully somebody else will weigh in
 

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

Top