triggering javascript confirm dialog via a function (not button event)
-
Hello everyone, I'm looking for a way to trigger a javascript confirmation dialog box and capture its value via a function as opposed to button events (as per all the tutorials I've found). The reasoning behind this is that are are 3 separate things that could trigger this dialog - 2 being button events, and one being page load if certain circumstances are met. Needless to say I don't want to write 3 separate functions for these if I don't have to, I'd rather just call the main confirm function from pageload and/or the button event handlers as appropriate. Does anyone have any ideas? Thanks in advance!
------------------- abort, retry, fail?
-
Hello everyone, I'm looking for a way to trigger a javascript confirmation dialog box and capture its value via a function as opposed to button events (as per all the tutorials I've found). The reasoning behind this is that are are 3 separate things that could trigger this dialog - 2 being button events, and one being page load if certain circumstances are met. Needless to say I don't want to write 3 separate functions for these if I don't have to, I'd rather just call the main confirm function from pageload and/or the button event handlers as appropriate. Does anyone have any ideas? Thanks in advance!
------------------- abort, retry, fail?
You could write two functions in form of a string, one is your confirm, and the other is the function that will capture the confirm value (val1, val2, etc). Then on the server side you will have to implement ICallbackEventHandler interface, incorporate the two methods that come with it (GetCallbackResult, and RaiseCallbackEvent). Next, register your javascript(RegisterClientScriptBlock), then tie them all up in a string that holds the value of 'GetCallbackEventReference'. Once that's done, then you will want to add the GetCallbackEventReference string to a control's "onclick" attribute, OR you can place it within yet another javascript that will get triggered at some point in time... I know, this sounds a little confusing, but maybe if you give me the specifics of your project I could try to write it for you (I just did something very similar to this yesterday and it worked!)
Nila Fridley
-
You could write two functions in form of a string, one is your confirm, and the other is the function that will capture the confirm value (val1, val2, etc). Then on the server side you will have to implement ICallbackEventHandler interface, incorporate the two methods that come with it (GetCallbackResult, and RaiseCallbackEvent). Next, register your javascript(RegisterClientScriptBlock), then tie them all up in a string that holds the value of 'GetCallbackEventReference'. Once that's done, then you will want to add the GetCallbackEventReference string to a control's "onclick" attribute, OR you can place it within yet another javascript that will get triggered at some point in time... I know, this sounds a little confusing, but maybe if you give me the specifics of your project I could try to write it for you (I just did something very similar to this yesterday and it worked!)
Nila Fridley
Or you could just register a little js - no need to implement anything else....seems like you're over-complicating things a little
"Now I guess I'll sit back and watch people misinterpret what I just said......" Christian Graus At The Soapbox
-
Or you could just register a little js - no need to implement anything else....seems like you're over-complicating things a little
"Now I guess I'll sit back and watch people misinterpret what I just said......" Christian Graus At The Soapbox
Rich, it all depends on exactly what he is intending on doing with the captured value... first off, he will have to write a function for the confirm, and one to capture value. Then if he needs to process the captured value on the server side, then he would most certainly need to create a 'receiver' js function, and give it an event reference, and call the referenced function from within the js that captures the value of the confirm. Without the event reference (or a complete page postback), the server won't be able to process anything. When you think about even the smallest asynchronous functionalities, in pure english it sounds very easy, but translating it to .net is rather 'screwy'
Nila Fridley
-
Rich, it all depends on exactly what he is intending on doing with the captured value... first off, he will have to write a function for the confirm, and one to capture value. Then if he needs to process the captured value on the server side, then he would most certainly need to create a 'receiver' js function, and give it an event reference, and call the referenced function from within the js that captures the value of the confirm. Without the event reference (or a complete page postback), the server won't be able to process anything. When you think about even the smallest asynchronous functionalities, in pure english it sounds very easy, but translating it to .net is rather 'screwy'
Nila Fridley
Sorry, but I fail to see why the need for the complexity.... Define a js function....
function confirmDialog()
{
res = confirm(.......)if (res)
{
document.getElementById ('someHiddenField').value = inputFromConfirm
}}
Then to call the function, just set the onclick handler of the buttons, and in Page_Load, Page.RegisterStartupScript for the third case.... Once the function is called, can either __doPostback or just call the default button's click event - look for the hidden value on't server side, et voila! Can you talk me through how you would implement this...why go to all the trouble and jumping through the hoops you seem to suggest?
"Now I guess I'll sit back and watch people misinterpret what I just said......" Christian Graus At The Soapbox
-
Sorry, but I fail to see why the need for the complexity.... Define a js function....
function confirmDialog()
{
res = confirm(.......)if (res)
{
document.getElementById ('someHiddenField').value = inputFromConfirm
}}
Then to call the function, just set the onclick handler of the buttons, and in Page_Load, Page.RegisterStartupScript for the third case.... Once the function is called, can either __doPostback or just call the default button's click event - look for the hidden value on't server side, et voila! Can you talk me through how you would implement this...why go to all the trouble and jumping through the hoops you seem to suggest?
"Now I guess I'll sit back and watch people misinterpret what I just said......" Christian Graus At The Soapbox
Uhh, Rich... I'm way too tired to sit down and type up a long long chunk of code just to prove a silly point! If you think I'm making things complicated, and if you don't know how ICallbackEventHandler interface works, then just read this article: http://www.codeguru.com/csharp/.net/net_asp/scripting/article.php/c11843/[^] There are lots and lots of resources out there that shed light on asp.net's client callbacks :-)
Nila
-
Uhh, Rich... I'm way too tired to sit down and type up a long long chunk of code just to prove a silly point! If you think I'm making things complicated, and if you don't know how ICallbackEventHandler interface works, then just read this article: http://www.codeguru.com/csharp/.net/net_asp/scripting/article.php/c11843/[^] There are lots and lots of resources out there that shed light on asp.net's client callbacks :-)
Nila
Oh calm down - I wasn't expecting you to give me chapter and verse - simpy trying to get a different perspective on things. That's one of the reasons why I like this place - since we can have an adult discussion about different approaches to a given problem. You obviously know something I don't, or are aware of a point I've missed, and I was only trying to engage you to discuss it. I mean really - did you wake up one morning and suddenly know EVERYTHING, or have you spoken to others and learned from what they say?
"Now I guess I'll sit back and watch people misinterpret what I just said......" Christian Graus At The Soapbox
-
Oh calm down - I wasn't expecting you to give me chapter and verse - simpy trying to get a different perspective on things. That's one of the reasons why I like this place - since we can have an adult discussion about different approaches to a given problem. You obviously know something I don't, or are aware of a point I've missed, and I was only trying to engage you to discuss it. I mean really - did you wake up one morning and suddenly know EVERYTHING, or have you spoken to others and learned from what they say?
"Now I guess I'll sit back and watch people misinterpret what I just said......" Christian Graus At The Soapbox
Im sorry if my post sounded like that, I wasn't angry by any means, Im actually a super nice girl. I was just very tired after working a long day... To answer your question on "did you wake up one morning and suddenly know EVERYTHING"; no, I am not the all-knowing since I am not God (not even close!). All I did was to try and help out some other person, but you had to start and argue with me.
Nila Fridley