473,382 Members | 1,258 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,382 software developers and data experts.

Confirm button in asp.net

Help, I’m trying to implement a confirm button on an asp.net page. I have it
attached to a asp:button control. In the button1 click event I call the
CreateConfirmBox subroutine. The Box comes up with the yes/No option ok. My
problem or question is: How do I determine which button was pressed? Below
are the 2 routines I’m using.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
CreateConfirmBox(Button1, "Do you want to close?")
End Sub
Public Shared Sub CreateConfirmBox(ByRef btn As WebControls.Button, _
ByVal strMessage As String)
btn.Attributes.Add("onclick", "return confirm('" & strMessage & "');")

End Sub

Any help will be appreciated,
Logger
Jul 21 '05 #1
5 8942
Hi,

On the client side, confirm returns true if OK was clicked and false for
Cancel. As per your code below, postback will happen only when user clicked
on OK. So, on the server-side, you can assume that OK was pressed on the
client-side.
"Logger" <Lo****@discussions.microsoft.com> wrote in message
news:21**********************************@microsof t.com...
Help, I'm trying to implement a confirm button on an asp.net page. I have
it
attached to a asp:button control. In the button1 click event I call the
CreateConfirmBox subroutine. The Box comes up with the yes/No option ok. My
problem or question is: How do I determine which button was pressed? Below
are the 2 routines I'm using.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
CreateConfirmBox(Button1, "Do you want to close?")
End Sub
Public Shared Sub CreateConfirmBox(ByRef btn As WebControls.Button, _
ByVal strMessage As String)
btn.Attributes.Add("onclick", "return confirm('" & strMessage &
"');")

End Sub

Any help will be appreciated,
Logger
Jul 21 '05 #2
Ok, but where do I check for the return true, In the Createconfirmbox or the
button1_click routine and How?
Logger

"Shiva" wrote:
Hi,

On the client side, confirm returns true if OK was clicked and false for
Cancel. As per your code below, postback will happen only when user clicked
on OK. So, on the server-side, you can assume that OK was pressed on the
client-side.
"Logger" <Lo****@discussions.microsoft.com> wrote in message
news:21**********************************@microsof t.com...
Help, I'm trying to implement a confirm button on an asp.net page. I have
it
attached to a asp:button control. In the button1 click event I call the
CreateConfirmBox subroutine. The Box comes up with the yes/No option ok. My
problem or question is: How do I determine which button was pressed? Below
are the 2 routines I'm using.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
CreateConfirmBox(Button1, "Do you want to close?")
End Sub
Public Shared Sub CreateConfirmBox(ByRef btn As WebControls.Button, _
ByVal strMessage As String)
btn.Attributes.Add("onclick", "return confirm('" & strMessage &
"');")

End Sub

Any help will be appreciated,
Logger

Jul 21 '05 #3
Hi,
You don't get the return value of confirm() on the server side directly. If
the button1_click is executed, it means the return value from confirm() is
true (per your logic). If the confirm() returns false (because user clicked
Cancel), then button1_click will not get executed since there is no
postback.

HTH,

"Logger" <Lo****@discussions.microsoft.com> wrote in message
news:D6**********************************@microsof t.com...
Ok, but where do I check for the return true, In the Createconfirmbox or the
button1_click routine and How?
Logger

"Shiva" wrote:
Hi,

On the client side, confirm returns true if OK was clicked and false for
Cancel. As per your code below, postback will happen only when user clicked on OK. So, on the server-side, you can assume that OK was pressed on the
client-side.
"Logger" <Lo****@discussions.microsoft.com> wrote in message
news:21**********************************@microsof t.com...
Help, I'm trying to implement a confirm button on an asp.net page. I have
it
attached to a asp:button control. In the button1 click event I call the
CreateConfirmBox subroutine. The Box comes up with the yes/No option ok. My problem or question is: How do I determine which button was pressed? Below
are the 2 routines I'm using.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
CreateConfirmBox(Button1, "Do you want to close?")
End Sub
Public Shared Sub CreateConfirmBox(ByRef btn As WebControls.Button, _
ByVal strMessage As String)
btn.Attributes.Add("onclick", "return confirm('" & strMessage &
"');")

End Sub

Any help will be appreciated,
Logger

Jul 21 '05 #4
Hi, Another problem with my routine. On the first pass it doesn’t seem to
work, It doesn't show the confirm box. I have to run it twice before it
displays. This of course is no good. Any suggestion on what I can do?
Logger

"Shiva" wrote:
Hi,
You don't get the return value of confirm() on the server side directly. If
the button1_click is executed, it means the return value from confirm() is
true (per your logic). If the confirm() returns false (because user clicked
Cancel), then button1_click will not get executed since there is no
postback.

HTH,

"Logger" <Lo****@discussions.microsoft.com> wrote in message
news:D6**********************************@microsof t.com...
Ok, but where do I check for the return true, In the Createconfirmbox or the
button1_click routine and How?
Logger

"Shiva" wrote:
Hi,

On the client side, confirm returns true if OK was clicked and false for
Cancel. As per your code below, postback will happen only when user

clicked
on OK. So, on the server-side, you can assume that OK was pressed on the
client-side.
"Logger" <Lo****@discussions.microsoft.com> wrote in message
news:21**********************************@microsof t.com...
Help, I'm trying to implement a confirm button on an asp.net page. I have
it
attached to a asp:button control. In the button1 click event I call the
CreateConfirmBox subroutine. The Box comes up with the yes/No option ok.

My
problem or question is: How do I determine which button was pressed? Below
are the 2 routines I'm using.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
CreateConfirmBox(Button1, "Do you want to close?")
End Sub
Public Shared Sub CreateConfirmBox(ByRef btn As WebControls.Button, _
ByVal strMessage As String)
btn.Attributes.Add("onclick", "return confirm('" & strMessage &
"');")

End Sub

Any help will be appreciated,
Logger


Jul 21 '05 #5
You are attaching the JS onClick script for confirm in the server-side
button click event. So, the confirm box appears only after you have pressed
the button at least once. If you have the CreateConfirmBox() in Page_Load,
it should prompt at the first time itself.

Sub Page_Load()
If (Not IsPostback) Then CreateConfirmBox(...)
End Sub
"Logger" <Lo****@discussions.microsoft.com> wrote in message
news:A2**********************************@microsof t.com...
Hi, Another problem with my routine. On the first pass it doesn't seem to
work, It doesn't show the confirm box. I have to run it twice before it
displays. This of course is no good. Any suggestion on what I can do?
Logger

"Shiva" wrote:
Hi,
You don't get the return value of confirm() on the server side directly. If the button1_click is executed, it means the return value from confirm() is
true (per your logic). If the confirm() returns false (because user clicked Cancel), then button1_click will not get executed since there is no
postback.

HTH,

"Logger" <Lo****@discussions.microsoft.com> wrote in message
news:D6**********************************@microsof t.com...
Ok, but where do I check for the return true, In the Createconfirmbox or the button1_click routine and How?
Logger

"Shiva" wrote:
Hi,

On the client side, confirm returns true if OK was clicked and false for
Cancel. As per your code below, postback will happen only when user clicked
on OK. So, on the server-side, you can assume that OK was pressed on the
client-side.
"Logger" <Lo****@discussions.microsoft.com> wrote in message
news:21**********************************@microsof t.com...
Help, I'm trying to implement a confirm button on an asp.net page. I have it
attached to a asp:button control. In the button1 click event I call the
CreateConfirmBox subroutine. The Box comes up with the yes/No option ok. My
problem or question is: How do I determine which button was pressed?

Below are the 2 routines I'm using.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
CreateConfirmBox(Button1, "Do you want to close?")
End Sub
Public Shared Sub CreateConfirmBox(ByRef btn As WebControls.Button, _
ByVal strMessage As String)
btn.Attributes.Add("onclick", "return confirm('" & strMessage &
"');")

End Sub

Any help will be appreciated,
Logger


Jul 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Doug O'Leary | last post by:
Hey, all; Apparently, I'm missing the concept. I'm writing a web app in perl to manage nagios configuration files. One of the things I'd like to do is to confirm an update via a popup window...
4
by: @sh | last post by:
Can anyone help out here please, we have a button that when pressed will alert the user, should they cancel no action is taken, however should they confirm, the script will disable the button and...
2
by: J Sahoo | last post by:
I have an asp button on my form. If user clicks the button then my Javascript code Confirm pops up with "Ok" & "Cancel" button. If the user clicks "Ok" from my pop-up then I do my vbMethod...
13
by: Chris | last post by:
I can create Javascript confirm message boxes during page creation, etc adding them to the button attributes (many good posts on this!). But how can I add this event after the button is pressed? I...
5
by: Dave | last post by:
I'm tearing my hair out over this one. Using VS 2003, inline (not code-behind), vb.net. I have a button (btnClear) that calls a vb routine that goes into sql server and truncates a table. ...
5
by: Logger | last post by:
Help, I’m trying to implement a confirm button on an asp.net page. I have it attached to a asp:button control. In the button1 click event I call the CreateConfirmBox subroutine. The Box comes...
8
by: rn5a | last post by:
I have gone through a no. of posts in this NewsGroup regarding my problem but alas, couldn't come across one which would have helped me in resolving the issue. My problem is this: An ASPX Form...
4
by: mamun | last post by:
Hi All, I have the following situation and am looking for answer in C#. I have a datagrid and putting checkbox next to each record. In the header I have a Delete button. I want users to...
3
by: ghjk | last post by:
I have a web page which is used to enter user data. In there I have 4 buttons named as "Submit, Confirm,Edit,Cancel". User should enter data and click "Submit " button. Then I want to display all...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.