Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi,

 

Have a checkbox on my form, that has the postback enabled. What I would like to do is to display a confirm dialog asking the user are they sure they want to do this if the checkbox is checked true. If they click ok, then that no problem, however if they check cancel, I want to reset the checkbox back to its previous value. The approach that I am using to display message dialogues and confirm dialogues is as follows:

1. I add the following between the </form> and </body> tags

<script>
  <asp:Literal id="ltlAlert" runat="server" EnableViewState="False">
  </asp:Literal>
</script>

 

2. I add a withEvent declaration into the form design section of the code-behind page.

Protected WithEvents ltlAlert As System.Web.UI.WebControls.Literal

 

3. I then declare a method to handle the displaying of the message dialogues

Private Sub DisplayMessage(ByVal Message As String, Optional ByVal operator As Int16 = 1)
       Message = Message.Replace("'", "\'")
       Message = Message.Replace(Convert.ToChar(10), "\n")
       Message = Message.Replace(Convert.ToChar(13), "")
       ' Display as JavaScript alert
       Select Case operator
           Case 1
               ltlAlert.Text = "alert('" & Message & "')"
           Case 2
               ltlAlert.Text = "confirm('" & Message & "')"
       End Select
   End Sub

 

Any suggests??

 

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...