is there a way to return javascript confirm box result to c#variable?
i need to use a confirm box for my code behind c#
messagebox.show can't be display out on the client side. so i'm not going to use it.
AJAX. i'm not so familiar with it. so i'm not going to use it.
jurkflash
Member
37 Points
77 Posts
confirmation box
Dec 27, 2010 08:41 AM|LINK
hi all,
is there a way to return javascript confirm box result to c#variable?
i need to use a confirm box for my code behind c#
messagebox.show can't be display out on the client side. so i'm not going to use it.
AJAX. i'm not so familiar with it. so i'm not going to use it.
public void confirmBox(string Message) { string script = "<script>"; script += "confirm('sure?')"; script += "</script>"; ClientScript.RegisterStartupScript(Page.GetType(), "confirm", script.ToString(), false); }the above code runs well with showing ok and cancel button.
can i do when user click on ok, it will point to other function?
i'm doing on the code behind, not the button.
Thanks all.....
Mikesdotnett...
All-Star
154955 Points
19872 Posts
Moderator
MVP
Re: confirmation box
Dec 27, 2010 09:10 AM|LINK
Clicking the OK button should cause a postback. That's the indicator to your server code that the OK button was clicked.
Beginning ASP.NET Web Pages with WebMatrix | My Site | Twitter
ajitsatpathy
Member
318 Points
99 Posts
Re: confirmation box
Dec 27, 2010 09:18 AM|LINK
In "confirmBox" function, instead of void (not return anything), you have to return boolean value. If yes, return true. Else return false.
In this way you can restrict page postback.
http://webxpertstalk.blogspot.com/
mudassarkhan
All-Star
78956 Points
13402 Posts
MVP
Re: confirmation box
Dec 27, 2010 09:19 AM|LINK
You can create your own server side confirm box using modal popup extender
http://mattberseth.com/blog/2007/10/yui_style_yesno_confirm_dialog.html
Contact me
tan_vision_1...
Participant
1178 Points
413 Posts
Re: confirmation box
Dec 27, 2010 09:25 AM|LINK
if(Selvalue=="Registrar") { var pend=confirm("Please Click Yes to View Total Pendancy"); if(pend==true) { window.location.href="Registrar_Pending.aspx"; } else { window.location.href="selectsearchtype.aspx?sid="+Selvalue; }jurkflash
Member
37 Points
77 Posts
Re: confirmation box
Dec 27, 2010 12:05 PM|LINK
public bool confirmBox() { string script = "<script>"; script += "confirm('sure?')"; script += "</script>"; ClientScript.RegisterStartupScript(Page.GetType(), "confirm", script.ToString(), false); } //can be done like this? public void functionA() { if(confirmBox()) //functionB(true) else //functionB(false) }can it?
jurkflash
Member
37 Points
77 Posts
Re: confirmation box
Dec 27, 2010 12:10 PM|LINK
public bool confirmBox() { string script = "<script>"; script += "confirm('sure?')"; script += "</script>"; ClientScript.RegisterStartupScript(Page.GetType(), "confirm", script.ToString(), false); } //can be done like this? public void functionA() { if(confirmBox()) //functionB(true) else //functionB(false) }can it?
jurkflash
Member
37 Points
77 Posts
Re: confirmation box
Dec 27, 2010 12:13 PM|LINK
thanks for the reply, when i'm advance in asp will go for it. i'm still newbie =)
jurkflash
Member
37 Points
77 Posts
Re: confirmation box
Dec 27, 2010 12:19 PM|LINK
i saw that before.
its not answering on my question.
jurkflash
Member
37 Points
77 Posts
Re: confirmation box
Dec 30, 2010 05:05 AM|LINK
guys...any help for me?