Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

Ignorance begins with I.
Posted

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

Ignorance begins with I.
Posted

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.

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)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...