Search:
Namespaces
Discussions
.NET v1.1
Feedback
JScript Confirm Box (extra functionality)
Messages
Related Types
This message was discovered on
ASPFriends.com 'aspngfreeforall' list
.
Rel Breedlove
Hi All,
I have a button:
<asp:Button id="CmdDeleteArticle"
Text="Delete Entire Article"
CommandArgument="CmdDeleteArticle"
OnClick="CMDButtonClick"
visible='<%# CheckDelete()%>'
runat="server"/>
and I use the following Sub for the onclick: (I stripped non-relavent code)
Sub CMDButtonClick(sender As Object, e As EventArgs)
Dim arg As String = CType(sender, Button).CommandArgument
Select Case arg
Case "CmdDeleteArticle"
DeleteArticle()
Case Else
'Do Nothing
End Select
End Sub
Since I am already using 'OnClick', how do I add a confirmation box? I know
I can use a regular html button with JScript and then check for button
pushed with:
If Len(Request.Form("cmdFilter")) > 0 Then
DeleteArticle()
End If
In my page load, but I would rather stick with using the
OnClick="CMDButtonClick"
I have programtically done this before, but never on a button ALREADY
containing an Onclick...
Any help would be appreciated.
Thanks
Rel
Reply to this message...
chris
you could use the button HTMLControl as an alternative. eg:
<input type="button" id="CmdDeleteArticle" value="Delete Entire Article"
runat="server" onClick="javascript:doConfirm();"
onServerClick="CMDButtonClick"/>
What happens here is this: the onClick event is set to a javascript function
that pops up your confirm box, and since the runat="server" attribute is
present, the onServerClick event will fire on postback. Of course, the
javascript will execute before postback.
hth,
-Chris Frazier
.NET Solution Developer
Velocity Databank, Inc.
www.velocitydatabank.com
-----Original Message-----
From: Rel Breedlove [mailto:
Click here to reveal e-mail address
]
Sent: Tuesday, August 06, 2002 10:43 AM
To: aspngfreeforall
Subject: [aspngfreeforall] JScript Confirm Box (extra functionality)
Hi All,
I have a button:
<asp:Button id="CmdDeleteArticle"
Text="Delete Entire Article"
CommandArgument="CmdDeleteArticle"
OnClick="CMDButtonClick"
visible='<%# CheckDelete()%>'
runat="server"/>
and I use the following Sub for the onclick: (I stripped non-relavent code)
Sub CMDButtonClick(sender As Object, e As EventArgs)
Dim arg As String = CType(sender, Button).CommandArgument
Select Case arg
Case "CmdDeleteArticle"
DeleteArticle()
Case Else
'Do Nothing
End Select
End Sub
Since I am already using 'OnClick', how do I add a confirmation box? I know
I can use a regular html button with JScript and then check for button
pushed with:
If Len(Request.Form("cmdFilter")) > 0 Then
DeleteArticle()
End If
In my page load, but I would rather stick with using the
OnClick="CMDButtonClick"
I have programtically done this before, but never on a button ALREADY
containing an Onclick...
Any help would be appreciated.
Thanks
Rel
| ASP.net DOCS =
http://www.aspng.com/docs
| [aspngfreeforall] member
Click here to reveal e-mail address
= YOUR ID
|
http://www.asplists.com/aspngfreeforall
= JOIN/QUIT
| news://ls.asplists.com = NEWSGROUP
Reply to this message...
Rel Breedlove
Thanks, but one small question...
This is what I came up with...
<asp:Button id="CmdDeleteArticle"
Text="Delete Entire Article"
CommandArgument="CmdDeleteArticle"
OnCommand="CommandBtn_Click"
CausesValidation="False"
visible='<%# CheckDelete()%>'
runat="server"/><br>
I had to put in the JScript progromatically, because it would error when I
just put it in with the button, complaining about the word, "Javascript" so
I did it this way..
Sub Page_Load()
CmdDeleteArticle.Attributes.Add("onclick","return confirm('Are you Sure
you want to delete this?');")
When ever I used OnServerClick="CMDButtonClick", The JScript Confirm worked
fine and postedback whenever they user clicks 'OK' but the CMDButtonClick
Sub was never getting kicked off...
I got around it by finding the
OnCommand="CommandBtn_Click"
but I am still curious to find out why the 'OnServerClick' never kicked off
my code? The way I had MY code was just replace OnCommand with
OnServerClick...
Any ideas?
No Hurry now that I have a work around
Thanks ALOT for the help
Rel
----- Original Message -----
From: "chris" <
Click here to reveal e-mail address
>
To: "aspngfreeforall" <
Click here to reveal e-mail address
>
Sent: Tuesday, August 06, 2002 12:46 PM
Subject: [aspngfreeforall] RE: JScript Confirm Box (extra functionality)
[Original message clipped]
Reply to this message...
System.EventArgs
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com