papa_k Posted November 24, 2003 Posted November 24, 2003 I want to be able to promt when a use clicks a form button, exit. I want a message box to appear so that they can click ok or cancel. is this possible? I see that i can use msgbox("Prompt",vbInformation,"The Title") but it doesnt seem to work what am i missing? Papa. Quote without time nothing ever ends
Administrators PlausiblyDamp Posted November 24, 2003 Administrators Posted November 24, 2003 You would need to use javascript for that. Have a look here http://www.w3schools.com/js/tryit.asp?filename=tryjs_confirm Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
papa_k Posted November 24, 2003 Author Posted November 24, 2003 where would the code that the link (and it is an excellent link) go if i want to have it called if a if() statement within the code for a button is reached? that may sound like a dumb question, but the web page buttons are built on vb code and this is java code? Quote without time nothing ever ends
zubie Posted November 24, 2003 Posted November 24, 2003 You can execute Javascript code from within the code behind try something like this Response.Write("<script language='javascript'>" & vbCrLf) Response.Write("var name = confirm("Press a button")") Response.Write("if (name == true)") etc .... Response.Write("</script>" & vbCrLf) hope this helps ZuBiE Quote
papa_k Posted November 24, 2003 Author Posted November 24, 2003 You can execute Javascript code from within the code behind try something like this Response.Write("<script language='javascript'>" & vbCrLf) Response.Write("var name = confirm("Press a button")") Response.Write("if (name == true)") etc .... Response.Write("</script>" & vbCrLf) hope this helps ZuBiE ultimately what i want is for a button to be pressed on a web form - EXIT - and then a message box to pop up, with Save? YES - NO - Cancel. Or something similar...all the java solutions dont seem to cover this. If this is not possible, just a click EXIT then msgbox appear would good. Quote without time nothing ever ends
*Experts* Bucky Posted November 24, 2003 *Experts* Posted November 24, 2003 (edited) You can add a little bit of JavaScript to a button that pops up a dialog with OK or Cancel. If the user clicks OK, the code for the button executes. Otherwise, nothing happens. This code can go in the Page.Load event or any code that executes before the page finished loading, where myButton is the name of the button control: myButton.Attributes.Add("onClick", "java[b][/b]script:return confirm('Would you like to exit?')"; Anyway, is that what you're looking for? [edit]To avoid confusion, I've fixed the 'javascript' bit. -VolteFace[/edit] Edited November 24, 2003 by Volte Quote "Being grown up isn't half as fun as growing up These are the best days of our lives" -The Ataris, In This Diary
maddirala Posted November 25, 2003 Posted November 25, 2003 try this This is java script function name() { var flag=window.confirm("Are you sure you want to Exit"); if (flag) { window.document.formname.submit(); } else { return false; } } call this function from ur submit button Quote
papa_k Posted November 26, 2003 Author Posted November 26, 2003 thanks for all the posts. Unfortunately it seems that it is not possible to have a message box that has mutiple options. E.g. --------------------------------- | Save? | | | | Yes - No - Cancel | --------------------------------- Papa. Quote without time nothing ever ends
tate Posted November 26, 2003 Posted November 26, 2003 Is this for a VB .NET application? If so, what about MessageBox.Show option? Quote
Moderators Robby Posted November 26, 2003 Moderators Posted November 26, 2003 Tate, since this is in the ASP.NET section and everyone is suggesting options using Javascript, my bet is that MessageBox will not work. Quote Visit...Bassic Software
Administrators PlausiblyDamp Posted November 26, 2003 Administrators Posted November 26, 2003 would a confirm box (yes / no) be any use here? http://www.w3schools.com/js/tryit.asp?filename=tryjs_confirm Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
maddirala Posted November 26, 2003 Posted November 26, 2003 Hi papa No means it's cancel only.y do u need again no and cancel Quote
papa_k Posted November 27, 2003 Author Posted November 27, 2003 The way that i intended that message box be used... The user has informaiton on the web form. This information they can change, once they have made there changes they would press exit. The exit buttong would bring up the message box option... Do you accept this information as true? Yes - would call a function and pass the information on one way. No - would call a funtion pass the information on another way. Cancel - would allow them to edit the information on the web page again. Quote without time nothing ever ends
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.