Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 24th, 2005, 12:33 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 119
Thanks: 0
Thanked 1 Time in 1 Post
Default HELP - trying to code for RETRY button

I am trying to convert this line of ASP code into my aspx.cs page so that when the user clicks on the RETRY button on the web page it goes back to the last page they were on:

strHTTP = trim(Request.ServerVariables("HTTP_REFERER"))

<input Type="Button" Value="Retry" Name="Retry" onClick="window.location='<%=strHTTP%>'">

I tried the following but got a compilation error stating no definition for history:

<asp:button id="retryButton" Text="Retry" Runat="server" OnClick="history.back()">

How do I do the same thing in my .aspx page?

Any help or direction would be appreciated.

Regards.
 
Old January 24th, 2005, 02:20 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

<asp:button id="retryButton" Text="Retry" Runat="server" OnClick="javascript:history.back()">

Though what is happening is it is mapping to the server event instead of the client. Try adding it through code-behind:

retryButton.Attributes.Add("onclick", "javascript:history.back");

Brian
 
Old January 24th, 2005, 02:44 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 119
Thanks: 0
Thanked 1 Time in 1 Post
Default

Brian,

Thanks for the help. I did add this second example: retryButton.Attributes.Add("onclick", "javascript:history.back");
to the CODE-BEHIND in the following event:

private void retryButton_Click(object sender, System.EventArgs e)
        {
            retryButton.Attributes.Add("onclick", "javascript:history.back()");
        }

However, what seems to happening is that the current ERROR PAGE that I am originally coming to when I get an error is not retrying the last page but this same ERROR PAGE that I got to.

Any suggestions would be appreciated. Thanks, again!!
 
Old January 24th, 2005, 03:34 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

You might have to use Response.Redirect

 
Old January 25th, 2005, 12:01 AM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Vadivel Send a message via Yahoo to Vadivel
Default

If you are going to use only history.back() or history.go(-1) then you could create a Html button instead of a server control. On the onClick of it call this js code.

Best Regards
Vadivel

MVP ASP/ASP.NET
http://vadivel.thinkingms.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Add a button with code into Excel hewstone999 Access VBA 0 March 18th, 2008 06:08 AM
Resolved! - code behind button won't execute dartcoach Access VBA 1 February 4th, 2008 06:17 PM
Help me by giving code for this search button csateesh ASP.NET 1.0 and 1.1 Professional 1 August 7th, 2007 07:40 AM
asp code for search button ct ASP.NET 1.0 and 1.1 Basics 2 August 25th, 2005 03:28 AM
moving a button in code goplayoutside VB.NET 2002/2003 Basics 2 April 22nd, 2004 01:40 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.