Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Confirmation window

Posted on 2006-07-24
5
Medium Priority
?
303 Views
Last Modified: 2008-02-01
Hi,

How can I popup a confirmation window in the following buton click event?

Private Sub Button1(byVal Sender as object, e as DatagridcommandeventARgs)handles Button1.Click
...
dim Total as integer = cmd.ExecuteScalar

if Total > 5 then
...I want popup a conf. window here showing the value 5 inthe window.
end if

' If user clicks OK then I want to execute the rest of the code otherwise just cancel the execution.
...
  the rest of the code like

ExecuteNonQuery
...

End Sub

Ayha1999
0
Comment
Question by:ayha1999
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17168997
Here is an example of something similar:

Adding JavaScript Confirm Delete Dialog to ASP Pages
http://www.gotocode.com/art.asp?art_id=78&

 Response.Write( "<SCRIPT Language='JavaScript'>")
 Response.Write( "if (document.forms['" & formName & "'])" )
 Response.Write( "document." & formName & ".onsubmit=delconf;" )

 Response.Write( "function delconf() {" )
 Response.Write( "if (document." & formName & ".FormAction.value == 'delete')" )
 Response.Write( "return confirm('Are you sure you want to delete this record? The delete cannot be undone!'); ")
 Response.Write( "}")
 Response.Write( "</SCRIPT>")


Notice the use of the 'confirm' Javascript function.

Bob
0
 
LVL 7

Author Comment

by:ayha1999
ID: 17169063
Hi,

How can display the 'Total' in the following statement? is tbe it stop the execution of the rest of the code if user click 'cancel'?

Response.Write( "return confirm('Are you sure you want to delete this record? The delete cannot be undone!'); ")

ayha


0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17170410
To allow cancel, set the 'onClick' attribute like this:

   Me.Button1.Attributes("onClick") = "javascript:return confirm('Are you sure you want to delete this record? The delete cannot be undone!');"

If you click 'Yes', it will post back, and if you click cancel, it won't.

Bob
0
 
LVL 7

Author Comment

by:ayha1999
ID: 17210681
HI,

I tried the sample but it doesn't fullfil my requirement. could u pls tell me how to use the sample provided in follwoing link with the follwoing sample?

http://www.codeproject.com/aspnet/NingLiangSimpleControl.asp

if Total > 5 then
...I want popup ther confirmation window here showing the value 5 inthe window. and if use clicks OK the process the rest of the code other stop processing.

end if

thanks in advance.

ayha
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 120 total points
ID: 17254230
If you look at the article, you will see this resulting Javascript code:

<INPUT type=hidden value='0' name='hiddenfield_name'>

<script language='javascript'>"

 if (confirm( ' + sMsg + '))"
 {
    document.forms[0].hiddenfield.value='1';"
    document.forms[0].submit();
 else
 {
   document.forms[0].hiddenfield_name.value='0';
 }
</script>

Bob
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question