Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 22nd, 2004, 02:10 PM
Friend of Wrox
 
Join Date: Oct 2003
Location: Cairo, , Egypt.
Posts: 336
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alyeng2000
Default how do i pop a client msg

i need to pop up a message(Yes/No) before continuing executing an event in CodeBehind (all asp.net code is written in CodeBehind code)
and base on the Message I Can Execute the Asp.net Code


Ahmed Ali
Software Developer
__________________
Ahmed Ali
Senior Software Developer
  #2 (permalink)  
Old January 22nd, 2004, 04:14 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You can't do that. Code-behind is server side. The client gets only the resulting HTML.

You'll need to build an intermediate step. Have the first event show a prompt on the page (or you could use javascript, it'll just be more complicated). That prompt has the Yes and No button and the "Yes" button from the prompt can call the event where you actually do what you need.

Peter
------------------------------------------------------
Work smarter, not harder.
  #3 (permalink)  
Old January 23rd, 2004, 03:54 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Quote:
quote:Originally posted by planoie
That prompt has the Yes and No button and the "Yes" button from the prompt can call the event where you actually do what you need.

Peter
------------------------------------------------------
Work smarter, not harder.
Peter,

Do you know how to submit the form from a "Yes/No" popup? I already have a "Confirm Delete?" prompt on my form, but SmartNavigation seems to be messing it up and when the original "Delete" button is pressed, it scrolls back up to the bottom of my datagrid. For other reasons, though, SmartNavigation is better being used than not.

My prompt and "Delete" button are below this so it gets hidden unless they scroll back down. Any ideas? Thanks.

J
  #4 (permalink)  
Old January 23rd, 2004, 04:01 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Let me clarify because I guess I just kind of asked what Ahmed did in the first post.

Isn't there a way to pass variables directly through the "__doPostBack" function that will let me submit what I want (in this example, if "Yes" is pressed then it will be deleted from the DB)? Thanks.

J
  #5 (permalink)  
Old January 24th, 2004, 03:54 AM
Friend of Wrox
Points: 3,558, Level: 25
Points: 3,558, Level: 25 Points: 3,558, Level: 25 Points: 3,558, Level: 25
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: California, USA
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

Nothing is impossible!I have an idea: lets try.
  • Add a Hidden_text box from HTML elements
  • make it [u]Run as Server Control</u> to have access from behind page
  • use a confirm in clint side by JavaScript & put the result to that Hidden_text
  • check ur Hidden_text vaule from behind page for ...

HTH, keep in touch.

Always:),
Hovik Melkomian.
  #6 (permalink)  
Old January 24th, 2004, 05:27 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

I think you guys are over-complicating things. JavaScript has a nice confirm method for this. Simply have your original Delete button call some JavaScript that asks the user for confirmation. If the user clicks Cancel, the server side event will not fire (the page will not submit to the server).

Here's a short example:
Code:
Code Behind:
DeleteButton.Attributes.Add("onclick", "return (confirm('Are you sure you want to delete this item?'));");
This code will add a onclick attribute to the button on the page. When clicked, it will ask the user for conformation. This code assumes the following button in the ASPX page:
Code:
<asp:Button id="DeleteButton" runat="server" Text="Button"></asp:Button>
Of course it's easy to attach this kind of behavior to other HTML form controls as well.

If this is not what you're after, I think Peter's suggestion is the way to go. Just have a Yes and a No button on your form. For each button, handle the Click event and either Delete the record, or take no action at all.

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
  #7 (permalink)  
Old January 24th, 2004, 03:46 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Yes Imar, maybe I am over-complicating this. I have used this in classic ASP, but I was unsure how go about it in .Net.

So I am assuming that by clicking "No" at the prompt, it cancels out the postback to server? Otherwise it proceeds with the click event of the delete button and no other code (client or server) is needed to postback to the server, correct?

I will try it and see if it works. Thanks.

J
  #8 (permalink)  
Old January 24th, 2004, 05:03 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Yes, exactly. When you click Cancel, the onclick event of the button will return false, so the browser won't know it has to submit something.
If you do click OK, the onclick event returns true, the form will be submitted to the server and the server side code for the button will proceed as normal.

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
  #9 (permalink)  
Old January 25th, 2004, 04:16 PM
Friend of Wrox
 
Join Date: Oct 2003
Location: Cairo, , Egypt.
Posts: 336
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alyeng2000
Default

thx IMAR , it works but i need also to do some thing if No Pressed


Ahmed Ali
Software Developer
  #10 (permalink)  
Old January 25th, 2004, 04:37 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

In that case, go with what Peter suggested and add a No and a Yes button to the page. On the server, do what you need to do in the handler for each of the two buttons.

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
connecting client to client (Socket programming) maricar C# 0 September 25th, 2008 04:34 AM
Not Responding msg.. dpkbahuguna Beginning VB 6 1 August 25th, 2007 11:35 AM
error msg aspsuraj BOOK: Wrox's ASP.NET 2.0 Visual Web Developer 2005 Express Edition Starter ISBN: 978-0-7645-8807-5 1 November 27th, 2006 08:30 PM
open a new pop-up from a pop-up crmpicco Javascript How-To 1 January 18th, 2005 10:48 AM
VBA winsock POP email client hooi Access VBA 0 December 23rd, 2003 04:03 AM



All times are GMT -4. The time now is 02:17 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.