My web application has two web pages page 1 and page2. I have a continue button in page 1 to navigate to page2. I enter or select some information in page1 which has textbox, dropdownlist and other controls. And I click on continue button to go to page2. But when i click on browser back button to go to previous page page1 i am loosing all the vlaues in page1. My question is how can i retain the values or information without loosing it. Thank you in advance.
one of the way is to keep those values in the session.
And load it back when you are on the page.
Related
in my project I have two pages, page1 and page2. In page1 I have few dropdown controls to filter the records from the db. And in the grid view I have the button as "View details". When I click the "view details button, the page has to redirect to page2 and complete details of that record will be viewed.
Now what I need is I have back button in page2. when I click that button, the page has to go back to page1 and page should display like how I left it, should not load as fresh page....
Since beginner to asp.net I couldn't find the solution for this issue.
Please provide with some example....
Very thanks in advance...
Try this in you viewdetails button click event:
Server.Transfer("Page2.aspx")
And similarly in your page2 back button click event
Server.Transfer("Page1.aspx")
The Server.Transfer method also has a second parameter—"preserveForm". If you set this to True, using a statement such as Server.Transfer("Page2.aspx", True), the existing query string and any form variables will still be available to the page you are transferring to.
A simple solution would be to keep any such filters that you have set in session.
This allows you to keep the filters active even when the user navigates away from the page.
You can have a button the Page1 to clear the filters.
Page1 Load:
if(!String.IsNullOrEmpty(Session["Filter1"]))
{
dropDownList1.Text = Session["Filter1"];
}
Page1 dropDownList1_SelectedIndexChanged
Session["Filter1"] = dropDownList1.Text;
I am using views concept in my asp.net form control.my first view consist of a form to capture user details.when user press continue it will move to the second view.
The problem is ,When user press the back button of the browser from the second view it doesn't move the the previous view instead move to the previous page in the browser history.
I wanted to move to the first view with the existing data in the form,when user press the back button of the browser.
You should perform a full page postback I guess, so that at client end your previous view will be saved in browser's history.
I have a page on which there are two drop down lists, based on the selection of those dropdown lists grid view is filled. In grid view there are imagebuttons. When user clicks on any of the image button, he/she is redirected to another page. Now when I click on the back button of the browser, I want page in the same state as it was before redirect. How can I achieve this goal??
use ASP.NET Multiview control instead of separate two pages this will create one page with two views which will effectively retain page state.
Please refer to these articles
http://www.beansoftware.com/ASP.NET-Tutorials/MultiView-Control.aspx
code project multiview
I am having an application where I am displaying an modal dialog if the page is getting loaded for first time but when i navigate to any other page within the web site then also the modal dialog get displayed what i need is modal diaolg should get displayed only for first time and not while navigating within web site. "Just one time display of modal dialog to user not again and again if user navigates within website"
The modal dialog is coming from javascript and i am using asp.net 3.5
and not using ispostback any suggestion or condition other than ispostback is needed
Is there any property of page which is true/false for first time the page is loaded and gets false/true when the user navigates to other page within website...?
any way/logic to do it ...?
Thanks,
Nilesh
There is no property that will allow you to determine whether the pageis accessed for the first time or not. One way to handle this is to use a Session variable where you could store whether the user has already visited the first page.
I have 2 aspx pages with C# code behind. Page one have 4 text boxes , one drop down and 2 buttons. Out of 2 buttons one if for appearing the second page as Popup ( as per system requirement. I could use here Ajax popup control , but requirement is different). So my page 2 has text box and button . on click of button of page2 textbox value will go in the database. and page will close. ok ? but same time, dropdown on the page1 should be fill come with fill up the records without refreshing the page1.some how the values in 4 textboxes should be there in textboxes... i tried on my best to elaborate problem.please guide.
You would have to use AJAX to populate the drop down list, which you can do using a web service. Another problem with this is that if you use the standard ASP.NET DropDownList control, and modify the list on the client, you may get an error because the dropdownlist expects the list provided to it from the previous load.
Alternatively, when the user closes page 2, it could call a method on page 1 that calls __doPostBack to force a page postback in page 1, so you could use server code to populate page 1.
A separate page is going to add to the challenges, it would be a lot easier to leverage teh AJAX popup IMHO.
HTH.
Seems like you have 2 pages Page1 and Page2. Clicking on a button from Page1 takes you to a popup page Page2. Then on submit of Page2 you need to refresh DropdownList on Page1 but you need PartialPostback instead of FullPagePostback.
If that is the case. You can javascript to do partialpostback:
http://www.asp.net/%28S%28ywiyuluxr3qb2dfva1z5lgeg%29%29/learn/ajax-videos/video-172.aspx
edit:
To call a method from popup page you need to access method of parent page like: parent.RefreshDropDown();
Reagards.