Solved

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

Posted on 2010-11-14
12
1,745 Views
Last Modified: 2012-05-10
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
Comment
Question by:kitesurf
  • 3
  • 3
  • 3
  • +2
12 Comments
 
LVL 10

Expert Comment

by:hosneylk
Comment Utility
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
 
LVL 23

Expert Comment

by:Rajkumar Gs
Comment Utility

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
 
LVL 2

Expert Comment

by:getnitincr
Comment Utility
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
 
LVL 2

Expert Comment

by:getnitincr
Comment Utility
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
 
LVL 2

Expert Comment

by:AarthiPrabakaran
Comment Utility
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
 
LVL 1

Author Comment

by:kitesurf
Comment Utility
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 10

Accepted Solution

by:
hosneylk earned 500 total points
Comment Utility
add another parameter to the url saing that the update should be bypassed
0
 
LVL 2

Expert Comment

by:AarthiPrabakaran
Comment Utility
use quertstring while redirecting
0
 
LVL 2

Expert Comment

by:AarthiPrabakaran
Comment Utility
REsponse.Redirect("home.aspx?var=true",false);
0
 
LVL 2

Expert Comment

by:getnitincr
Comment Utility
apart from url ,session to store state you can also use hidden field.....
0
 
LVL 1

Author Comment

by:kitesurf
Comment Utility
sounds good hosneylk.  what does the comma false mean at the end of the response.redirect hosneylk?
0
 
LVL 1

Author Closing Comment

by:kitesurf
Comment Utility
good
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now