473,406 Members | 2,894 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,406 software developers and data experts.

back button problem! Help Please C#

product page has datalist control with paging implemented by gridview control, ProductDetail is the second page with back button which will take the user to the previous page.
The problem is when i go to second page in the datalistcontrol and click back button in productdetail page, even the browser back button dosent work, the previous page is not displayed and gives me "Page not found" Error. Any ideas how to make it work

<input id="Button1" type="button" value="Back to Product List" onclick="javascript:history.go(-1)" class ="btn"/>

This is Products.aspx.cs

protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["p"] != null)
{
CategoryID = c.ToInteger(Request.QueryString["p"].ToString());

}
if (!(IsPostBack))
{
DisplayProduct();

}
}

protected void DisplayProduct()
{
System.Data.SqlClient.SqlConnection Con = new System.Data.SqlClient.SqlConnection();
Con.ConnectionString = ConfigurationManager.AppSettings["ConnectionString"];
System.Data.SqlClient.SqlCommand Cmd = new System.Data.SqlClient.SqlCommand();
Cmd.Connection = Con;
Cmd.CommandType = CommandType.StoredProcedure;
Cmd.Parameters.Add("@CategoryID", SqlDbType.Int);
Cmd.Parameters["@CategoryID"].Value = CategoryID;

Con.Open();
Cmd.CommandText = "name";
SqlDataAdapter da = new SqlDataAdapter(Cmd);
DataSet mydt = new DataSet();
da.Fill(mydt);
int nRowCount = mydt.Tables[0].Rows.Count;
int maxrecords = (this.dgPager.CurrentPageIndex * this.dgPager.PageSize);
da.Fill(mydt, maxrecords, this.dgPager.PageSize, "name");
this.dgPager.VirtualItemCount = nRowCount;
this.dgPager.DataSource = mydt.Tables[1].DefaultView;
this.dgPager.DataBind();
this.dList.DataSource = mydt.Tables[1].DefaultView;
this.dList.DataBind();
lblPageIndex.Text = this.dgPager.CurrentPageIndex.ToString();
Session["PageIndex"] = lblPageIndex.Text.Trim();
if (Con.State == ConnectionState.Open)
{
Con.Close();

Cmd = null;
Con = null;

}
}
Thank you, Shilpa.
Mar 22 '07 #1
2 5615
sani723
117 100+
<input id="Button1" type="button" value="Back to Product List" onclick="javascript:history.go(-1)" class ="btn"/>

this code is working fine to me, can u type the name of the both pages.
Mar 22 '07 #2
amrraj
2
Use history.back()

That is

onclick="javascript:history.back()"
Mar 22 '07 #3

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

Similar topics

1
by: Peter D. Dunlap | last post by:
Hello, I realize that this may not be the best place to ask this question, through the application is asp.net. I also realize that questions about disabling the back button are generally met...
8
by: Galina | last post by:
Hello I have 6 dependent list boxes on my ASP page:  Faculty;  Lecturer;  Course;  Course occurrence;  Group;  Week commencing date. When faculty is selected, lists of lecturers and...
1
by: Johan Nedin | last post by:
Hello! I am having a problem with the @OutputCache page directive and Web browser Back Buttons. Problem: After setting <%@ OutputCache Location="None" %> on my pages I get the "Warning!...
8
by: Shimon Sim | last post by:
Hi, Every time I write ASP.NET application I have the same problem - Back button on the browser is my enemy. I have to tell client avoid using "Back" button and if you use it make sure to refresh...
29
by: Tom wilson | last post by:
I can't believe this is such an impossibility... I have an asp.net page. It accepts data through on form fields and includes a submit button. The page loads up and you fill out some stuff. ...
6
by: tshad | last post by:
I am trying to set up a Javascript popup box that has a way of sending back a message to asp.net on how to process some data. At the moment I am just doing: ...
5
by: ns21 | last post by:
How can the browser back button be disabled If the form is submitting information to other pages or submitting to itself or using redirections. I tried the tweaks like history.forward(1) in each...
7
by: mohammed.naghman | last post by:
Hi, I have 2 submit buttons in a jsp page. One of them takes me to page2.jsp and also passes the values enetered to page2.I have a link in the page2 that does a history.back to come to the...
8
by: =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?= | last post by:
I the page knows there was a cross post back. but i can not find the control. (asp.net 3.5) calling page has a master calling control: <asp:Button ID="btnSendAlert" runat="server" Text="Go"...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.