473,379 Members | 1,252 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Page Layout back to default when Browser back button is pressed...

rrocket
116 100+
I have a form that has various tables that are hidden. When the user selects a number from the DDL the corresponding number of tables shows up (using javascript). When the submit button is clicked it carries the values to the next page. The issue is when the user clicks the browser back button the page only shows 1 table (default setup) and not the 3 or 4 it had when it send to the next page.

Is there a way to get the page to keep the correct amount of tables showing with a postback?

Sorry if the title is vague, but it is the best I could come up with. If anyone needs something clarified let me know.
Aug 24 '09 #1
8 3864
gits
5,390 Expert Mod 4TB
since you did that with javascript you need some mechanism to 'know' the 'correct numbers of tables' in the first page so onload of it you could either read a cookie or make serverrequest where you have stored the information (DB or it seems that a session would be better) ... then execute the javascript to create the correct amount of tables ...

kind regards
Aug 25 '09 #2
ssnaik84
149 100+
use querystrings.
that is, on ddlXXX_SelectedIndexChanged, postback page with related value as querystring. it will help you to maintain history.
Aug 31 '09 #3
gits
5,390 Expert Mod 4TB
it is quite difficult (i would say impossible) to use a querystring with the browsers back- or forward buttons since you don't control them and don't know when the user will click them? as far as i'm aware a querystring is attached to a uri, how could that be done in that case?

kind regards
Aug 31 '09 #4
ssnaik84
149 100+
@gits
ok.. i will explain it..
have you checked history of browser? it stores urls with paramenters (that is querystring) this history is available in your back and fwd buttons.

when you press back button, a page (with particular url and parameters) is loaded.
here you can hide/show tables (on page_load event) by checking querystring value.
Expand|Select|Wrap|Line Numbers
  1. protected void Page_Load(object sender, EventArgs e)
  2. {
  3.  string paramValue = Request.QueryString["case"];
  4.  switch (paramValue)
  5.  {
  6.  case 1: showTable1and2();
  7.  break;
  8.  case 2: showTable3and4();
  9.  break;
  10.  :
  11.  :
  12.  }  
  13.  
  14.  
  15.  
and on DropDownList1_SelectedIndexChanged event, you can postback page with appending querystring value or simply
Expand|Select|Wrap|Line Numbers
  1. protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
  2. {
  3.  Response.Redirect("samepage.aspx?case="+ DropDownList1.SelectedValue);
  4. }
Aug 31 '09 #5
gits
5,390 Expert Mod 4TB
hmmm ... sounds reasonable ... i never use querystrings since i always use ajax and so i think that you know what you're talking about :) ... thank you for the insight :)

kind regards,
gits
Aug 31 '09 #6
Frinavale
9,735 Expert Mod 8TB
Normally controls such as DropDownLists do not use the query string. In fact they normally call a JavaScript method (__doPostback) when they cause the page to postback to the server.

I don't think that I would use query string.
I'd use HiddenFields instead.

HiddenFields are accessible in both the browser and in your server code. You could set a HiddenField with the number of tables to show whenever you use JavaScript to show them.

Now when the user hits the back button, and the cached version of the page is reactivated....you can should be able to use the values in the HiddenFields to determine how many tables to display.
Aug 31 '09 #7
ssnaik84
149 100+
Yes, but it's always better not to develop an application, by taking something for granted.. :)
what if user has disabled cache, cookies etc.
I have seen many cyber cafes disable these settings for security reasons..
I still dont get why the hell they do that, instead of using good antivirus package.. :)
Sep 1 '09 #8
Frinavale
9,735 Expert Mod 8TB
I just tried running the FireFox under those settings.

When I did, the back button was not available to me at all...so this leads me to conclude that under those settings this "back button pressed" problem doesn't exist.

When you hit the back button of a web browser a cached version of the web page is displayed......

Anything done on the page through Ajax calls, or using JavaScript are not saved in the cached version. A cached version will only be saved for when the full page is sent down from the server...(as apposed to partial page information sent down during Ajax requests).

This is why the JavaScript settings are lost when you move to another page, then hit the back button in the browser...the browser's "cached" version of the webpage is loaded.

In this case, I'm not even sure if the hidden fields would help....

The OP should get back to us regarding whether or not either the query string suggestion, or the hidden fields suggestion worked...

I'm not even sure how you would modify the query string really.

You certainly can't do this using JavaScript...it goes against browser security restrictions.

You'd have to set the Query String server side...in which case you would have to do a Full Page postback to the server...in which case the cached version of the page will end up showing the selected tables anyways and seeing that the tables were set using JavaScript it'd be pointless to full page post back to the server just to tell the server how many tables to display...because then you'd have to have the server set the visibility of the tables over again....you'd have to do double the work.
Sep 1 '09 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Biguana | last post by:
Hi, Just wondering if anyone can help here. We have a site where most of the site opens in a window with no toolbars or menubar: window.open('mypage.aspx','self','toolbar=0, menubar=0, etc,...
2
by: Ersin Gençtürk | last post by:
I show errors as popup boxes via alert() but I write this scripts in header of html page.So if there is an error on the server side , in the next postback a popup shows the error via alert , this...
15
by: Nathan | last post by:
I have an aspx page with a data grid, some textboxes, and an update button. This page also has one html input element with type=file (not inside the data grid and runat=server). The update...
3
by: Shimon Sim | last post by:
Hi Is it possible to make sure that the page doesn't show in browser history and won't effect Back button. The problem is that every postback shows as another entry for "Back" button and user...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
7
by: Schmidty | last post by:
Okay...I have another 'newbie' question; I have a function that loads a page and the action is $_SERVER; In the form that is in a function(method?) within a class a variable is passed back to...
1
by: Rob | last post by:
I know this is an old one, considering how many posts I found on it but I just wondered if any best practises had popped up recently, especially as Ajax has increased JavaScript and DHTML's...
3
by: =?Utf-8?B?cHJhZGVlcF9UUA==?= | last post by:
Hi All, Can anyone please explain me why I am not able to disable Browser caching in ASP.net by writing the following code Response.Buffer = true; Response.ExpiresAbsolute =...
8
by: Harvey Schmidlapp | last post by:
I have a fairly complex form (generated by means of an ASP 3 page). The form is used to define a query against a database. After running a query, the user hits their browser's back button and goes...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.