nate Posted March 5, 2007 Posted March 5, 2007 OK, this might be a dumb one but I am a little confused I am newer to the asp side of things so sorry if it is a stupid one. I am using VB.Net to make my aspx pages. I am using java script to show message boxes. I want to make a yes/no message box and make something happen on the code side of things. I used to use something like dim result result=msgbox("Do You want this feature", vbyesno) if result=vbyes then blah blah blah but how do I comunicate the java script alert result to trigger some code in my .vb file? Or can I use some sort of message box? Thanks. Quote Ignorance begins with I.
nate Posted March 5, 2007 Author Posted March 5, 2007 OK I am using this below: Public Function ConfirmFood() Dim Alert As New Label Alert.Text = "<script language='vbscript'>" & _ vbNewLine & "Confirm(" & """" & "Do You want some food?" & """" & ")" & _ vbNewLine & "return true; </script>" Page.Controls.Add(Alert) End Function How can I return the value? If I do this: Public Function ConfirmFood() Dim Alert As New Label Alert.Text = "<script language='vbscript'>" & _ vbNewLine & "Confirm(" & """" & "Do You want some food?" & """" & ")" & _ vbNewLine & "return true; </script>" Page.Controls.Add(Alert) Return Alert End Function It errors out because Alert is a label. Please Help. Thanks Quote Ignorance begins with I.
mike55 Posted March 6, 2007 Posted March 6, 2007 Hi Nate Here is what I do for the confirm dialog/messagebox using javascript: In my page load method I have the following line of code: btnSend.Attributes.Add("onclick", "if(confirm('Are you sure you want to do this?')){}else{return false}") I then have my normal btnSend_Click method that handles the button click. Just make sure that your btnSend is an asp.net button. When you click the button, you will get a javascript dialog asking you the above question, you will be give to two options, Ok or Cancel. I still haven't figured out how to changed this to Yes and No. You would probabily need to create your own javascript button. Now if you click on the OK button, the javascript will allow you to proceed to the btnSend_Click method. If you click on the Cancel button, then the javascript will simply act as if you never click the button. Hope this helps. Mike55. Quote A Client refers to the person who incurs the development cost. A Customer refers to the person that pays to use the product. ------ My software never has bugs. It just develops random features. (Mosabama vbforums.com)
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.