Click here to Skip to main content
15,892,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello. I have some html pages. On which I have wrote code that, when page is not postback, that is when it loads for the first time. It will store something in database. It is working fine. But my issue is, when I click on back button and the page again loads, it considers it as Not postback only. So, it again store data in database. Which i don't want. How to make a page postback when user goes back to it?
I tried to write below code on every page. But it isn't working.
<script language='text/javascript'>
setTimeout('__doPostBack('__Page','')', 10)
</script>


I need to make a page postback after it is loaded fr the another time.
Thnak you.
Posted
Updated 28-Nov-13 23:18pm
v2
Comments
JoCodes 29-Nov-13 5:05am    
Whats the code you have tried?

1 solution

I got the solution actually i make a mistake in understanding your question sorry for inconvinience.
Now Solution for your problem: actually page_load event in code behind gets executed before javascript function so what you can do is use a session varibale like below.

In your page in which you want to make it post back
use below code

C#
protected void Page_LoadComplete(object sender, EventArgs e)
{
    if (Session["MakePostBack"] == null )
    {
        if (!IsPostBack)
            FillGrid();
    }
}




And in rest all pages where ever you are redirectiong to from this page

C#
Session["MakePostBack"] = "PostItBack";


Hope This Helps!!!
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900