Need help with button click and java code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

i have a back button inside the code i have the following:

Response.Redirect("javaScript:history.go(-1)");

I can't get the thing to work like i want it to, i want the user to click
the button and to return to whatever page they came from ...

i can have a link button that works with this: javaScript:history.go(-1)

But i need a button instead of a link.

Also is there anyway to display a Yes / No dialog when a user hits a button
on a webpage?
 
Artmic,

These things do not require a postback, you could just insert a html button
on your page (without runat="server" tag) similar to the following:

<input type="button" value="previous page" onclick="if (confirm('Are you
sure?')){history.back(1);}return false;" />

HTH
 
HI,
i tried what you suggested, and it works for the input button .

The only problem is that i'm using the Infragistics controls, and the input
button does not look like one of theirs, got a whole Office type look to the
interface going.

Is there any way to do this without an input button type?
Is it possible to do this with a System.Web.UI.WebControls.Button object?
i guess not right?
 
Easy: just add the following code in Page_PreRender event:
C#:
MyAspButton.Attributes["onclick"] = "if (confirm('Are you
sure?')){history.back(1);}return false;";
VB:
MyAspButton.Attributes("onclick") = "if (confirm('Are you
sure?')){history.back(1);}return false;"

Please note "return false" added to the end - this is needed so that
standard postback does not get triggered.

HTH
 
Back
Top