• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2385
  • Last Modified:

Why onClick response.redirect to same page do isPostBack on PageLoad equal false?

Why onClick response.redirect to same page do isPostBack on PageLoad equal false? How do i make it equal true? thanks.

it seems autopostback=true works on the first page load after onclick button, but at the end of code after page redirect to same page, page load starts again with is postback false.
0
kitesurf
Asked:
kitesurf
  • 3
  • 3
  • 3
  • +2
1 Solution
 
hosneylkCommented:
because it's not a postback. instead it triggers an HTTP GET from the browser. Not a POST. to make it equal to true you'll have to make a POST. so don't do a response.redirect. simply let the form submit itself which is the default behavior.
0
 
Rajkumar GsSoftware EngineerCommented:

If you really want to do the PostBack from the same page, do a trick like this. But it will work.

First redirect to a temporary page. (something like 'Redirect.aspx')
Then in the pageload of that page, write code to redirect to your actual page (previous page)

Regards
Raj
0
 
getnitincrCommented:
I don't think IsPostBack should ever be true if the page is being hit from a
Response.Redirect. Response.Redirect sends back a HTTP/302 to the browser.
When receiving a HTTP/302 in response to a HTTP POST, a properly behaving
client (e.g. IE) will perform a HTTP GET on the new URL and thus will not
POST the form data to the new page.

0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
getnitincrCommented:
the step involved:    If your doing a Response.Redirect the it is NOT considered a postback.  The response.direct starts a whole new page request.  So if you your button is doing that the order of operations is happening like this:

Button Clicked
Page_Load (IsPostBack = true)
Button Event Code Runs
Response.Redirect Fires
Page_Load (IsPostBack = false, because you did a response.redirect)
Done.
0
 
AarthiPrabakaranCommented:
Hi,
Use session variable to find whether ispostback or not ..

before redirecting set session variable to true  . so on page load u can check it .
0
 
kitesurfAuthor Commented:
thanks for the responses.  i will try the session variable.  this could get messy in sharepoint.  on click i pass variables in response.redirect so when page loads and ask ispostback , i need it to say true to bypass any code that would use the variables in the url to update database.  any other ideas.  
0
 
hosneylkCommented:
add another parameter to the url saing that the update should be bypassed
0
 
AarthiPrabakaranCommented:
use quertstring while redirecting
0
 
AarthiPrabakaranCommented:
REsponse.Redirect("home.aspx?var=true",false);
0
 
getnitincrCommented:
apart from url ,session to store state you can also use hidden field.....
0
 
kitesurfAuthor Commented:
sounds good hosneylk.  what does the comma false mean at the end of the response.redirect hosneylk?
0
 
kitesurfAuthor Commented:
good
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

  • 3
  • 3
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now