Click here to Skip to main content
15,895,283 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionPostback problem from ASP.NET page Pin
LancashireLad10-Aug-07 6:10
LancashireLad10-Aug-07 6:10 
AnswerRe: Postback problem from ASP.NET page Pin
Michael Sync10-Aug-07 6:54
Michael Sync10-Aug-07 6:54 
GeneralRe: Postback problem from ASP.NET page Pin
LancashireLad10-Aug-07 7:32
LancashireLad10-Aug-07 7:32 
GeneralRe: Postback problem from ASP.NET page Pin
LancashireLad10-Aug-07 8:56
LancashireLad10-Aug-07 8:56 
GeneralRe: Postback problem from ASP.NET page Pin
Michael Sync10-Aug-07 16:21
Michael Sync10-Aug-07 16:21 
AnswerRe: Postback problem from ASP.NET page Pin
Guffa10-Aug-07 9:41
Guffa10-Aug-07 9:41 
GeneralRe: Postback problem from ASP.NET page Pin
LancashireLad10-Aug-07 10:41
LancashireLad10-Aug-07 10:41 
AnswerRe: Postback problem from ASP.NET page Pin
Fred_Smith10-Aug-07 11:44
Fred_Smith10-Aug-07 11:44 
This is very odd - yes, hitting Cancel shouold stop the postback; and you are also quire correct in that you need only add the JS once, the first time the page is loaded.

There really is no reason I can see why this shouldn't work - unless you have javascript disabled in your browser, perhaps..?

The simple page below, based on your code, works fine for me in both IE and Firefox - try copying it to your web-folder and running it. If it works, then there is something going on elsewhere on your page...

Fred


<%@ Page Language="vb" debug="true" %>
<script runat="server">
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
If Not Page.IsPostBack Then
CreateConfirmBox(btnDelete, "Are you sure you want to delete this user?")
else
litX.text += "Postback<br>"
End If
End Sub

Private Sub CreateConfirmBox(ByRef btn As WebControls.LinkButton, ByVal strMessage As String)
btn.Attributes.Add("onclick", "return confirm('" & strMessage & "');")
End Sub
</script>
<HTML>
<HEAD>
<title></title>
</HEAD>
<body >
<form id="Form1" runat="server">
<asp:Literal runat="server" id="litX"></asp:Literal>
<asp:LinkButton ID="btnDelete" runat="server" Text="Delete" />
</form>
</body>
</HTML>
GeneralRe: Postback problem from ASP.NET page Pin
LancashireLad11-Aug-07 3:16
LancashireLad11-Aug-07 3:16 
GeneralRe: Postback problem from ASP.NET page Pin
LancashireLad11-Aug-07 3:25
LancashireLad11-Aug-07 3:25 
QuestionCalculate distinces between 2 location Pin
DonVBguy10-Aug-07 5:26
DonVBguy10-Aug-07 5:26 
AnswerRe: Calculate distinces between 2 location Pin
Guffa10-Aug-07 5:56
Guffa10-Aug-07 5:56 
AnswerRe: Calculate distinces between 2 location Pin
Jon Sagara10-Aug-07 8:45
Jon Sagara10-Aug-07 8:45 
QuestionHow to get or set value/text of disabled dropdown list in java script Pin
here2learn10-Aug-07 5:19
here2learn10-Aug-07 5:19 
AnswerRe: How to get or set value/text of disabled dropdown list in java script Pin
Guffa10-Aug-07 5:28
Guffa10-Aug-07 5:28 
GeneralRe: How to get or set value/text of disabled dropdown list in java script Pin
here2learn12-Aug-07 18:50
here2learn12-Aug-07 18:50 
QuestionOverFlow Property in HTML 4.01 Pin
nandhububbly10-Aug-07 4:05
nandhububbly10-Aug-07 4:05 
AnswerRe: OverFlow Property in HTML 4.01 Pin
Vasudevan Deepak Kumar10-Aug-07 4:08
Vasudevan Deepak Kumar10-Aug-07 4:08 
GeneralRe: OverFlow Property in HTML 4.01 Pin
nandhububbly10-Aug-07 4:15
nandhububbly10-Aug-07 4:15 
QuestionHow to hide Menubar of IE in a web application? Pin
garimajain_mca10-Aug-07 4:03
garimajain_mca10-Aug-07 4:03 
AnswerRe: How to hide Menubar of IE in a web application? Pin
Vasudevan Deepak Kumar10-Aug-07 4:06
Vasudevan Deepak Kumar10-Aug-07 4:06 
QuestionPop up window problem Pin
ragavan10-Aug-07 2:23
ragavan10-Aug-07 2:23 
Questionhow to Store Text files into SQL SERVER 2000 Pin
Adapala10-Aug-07 2:20
Adapala10-Aug-07 2:20 
AnswerRe: how to Store Text files into SQL SERVER 2000 Pin
Blue_Boy10-Aug-07 2:29
Blue_Boy10-Aug-07 2:29 
AnswerRe: how to Store Text files into SQL SERVER 2000 Pin
leckey10-Aug-07 3:54
leckey10-Aug-07 3:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.