 |
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

January 22nd, 2004, 02:10 PM
|
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 336
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

January 22nd, 2004, 04:14 PM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
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.
|
|

January 23rd, 2004, 03:54 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
|
|
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
|
|

January 23rd, 2004, 04:01 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
|
|
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
|
|

January 24th, 2004, 03:54 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
|
|
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.
|
|

January 24th, 2004, 05:27 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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.
|
|

January 24th, 2004, 03:46 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
|
|
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
|
|

January 24th, 2004, 05:03 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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.
|
|

January 25th, 2004, 04:16 PM
|
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 336
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
thx IMAR , it works but i need also to do some thing if No Pressed
Ahmed Ali
Software Developer
|
|

January 25th, 2004, 04:37 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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.
|
|
 |