Pop-up?message box?

Discussion in 'ASP .Net Web Controls' started by Chris, Jun 16, 2004.

  1. Chris

    Chris Guest

    What is the best way to display pop-up messages, i.e. Confirmation, etc.?
    I'm using vb in asp.net.
    I've read another posting on the 'confirmation' subject but am a little unclear.
    I'd like to confirm a delete operation using a pop-up. On button, once clicked, goes straight to the Sub that deletes the record.

    Should I place a condition in the sub asking the user to confirm delete?

    I normally use a JavaScript routine that returns confirmation. But if I have the button going to the Sub then how could I also confirm?

    <asp:Button Text="Delete" class="label" OnClick="deleteuserinfo" ID="btndeleteuser" Runat="server" />

    Thanx!!!
     
    Chris, Jun 16, 2004
    #1
    1. Advertising

  2. Hi Chris,

    Here's one approach. Add the client-side script during the Load event and
    put it into the button.

    You proceed with the deletion only if the confirm() method returns true:

    Private Sub Page_Load _
    (ByVal sender As System.Object, _
    ByVal e As System.EventArgs) _
    Handles MyBase.Load
    btndeleteuser.Attributes.Add("onclick", _
    "javascript:return confirm('Delete it?');")
    End Sub

    Private Sub btndeleteuser_Click _
    (ByVal sender As System.Object, _
    ByVal e As System.EventArgs) _
    Handles btndeleteuser.Click
    Response.Write("Deleted")
    End Sub

    <form id="Form1" method="post" runat="server">
    <asp:Button Text="Delete" class="label" ID="btndeleteuser" Runat="server"
    />
    </form>

    Does this help?

    Ken
    Microsoft MVP [ASP.NET]


    "Chris" <> wrote in message
    news:...
    > What is the best way to display pop-up messages, i.e. Confirmation, etc.?
    > I'm using vb in asp.net.
    > I've read another posting on the 'confirmation' subject but am a little
    > unclear.
    > I'd like to confirm a delete operation using a pop-up. On button, once
    > clicked, goes straight to the Sub that deletes the record.
    >
    > Should I place a condition in the sub asking the user to confirm delete?
    >
    > I normally use a JavaScript routine that returns confirmation. But if I
    > have the button going to the Sub then how could I also confirm?
    >
    > <asp:Button Text="Delete" class="label" OnClick="deleteuserinfo"
    > ID="btndeleteuser" Runat="server" />
    >
    > Thanx!!!
     
    Ken Cox [Microsoft MVP], Jun 16, 2004
    #2
    1. Advertising

  3. Chris

    Chris Guest

    I didn't really understand, then I added it to my Page Load and it works. So it appears to put the Javascript routine (Like I've used before) in the button attributes. Cool!

    Thanx.


    "Ken Cox [Microsoft MVP]" wrote:

    > Hi Chris,
    >
    > Here's one approach. Add the client-side script during the Load event and
    > put it into the button.
    >
    > You proceed with the deletion only if the confirm() method returns true:
    >
    > Private Sub Page_Load _
    > (ByVal sender As System.Object, _
    > ByVal e As System.EventArgs) _
    > Handles MyBase.Load
    > btndeleteuser.Attributes.Add("onclick", _
    > "javascript:return confirm('Delete it?');")
    > End Sub
    >
    > Private Sub btndeleteuser_Click _
    > (ByVal sender As System.Object, _
    > ByVal e As System.EventArgs) _
    > Handles btndeleteuser.Click
    > Response.Write("Deleted")
    > End Sub
    >
    > <form id="Form1" method="post" runat="server">
    > <asp:Button Text="Delete" class="label" ID="btndeleteuser" Runat="server"
    > />
    > </form>
    >
    > Does this help?
    >
    > Ken
    > Microsoft MVP [ASP.NET]
    >
    >
    > "Chris" <> wrote in message
    > news:...
    > > What is the best way to display pop-up messages, i.e. Confirmation, etc.?
    > > I'm using vb in asp.net.
    > > I've read another posting on the 'confirmation' subject but am a little
    > > unclear.
    > > I'd like to confirm a delete operation using a pop-up. On button, once
    > > clicked, goes straight to the Sub that deletes the record.
    > >
    > > Should I place a condition in the sub asking the user to confirm delete?
    > >
    > > I normally use a JavaScript routine that returns confirmation. But if I
    > > have the button going to the Sub then how could I also confirm?
    > >
    > > <asp:Button Text="Delete" class="label" OnClick="deleteuserinfo"
    > > ID="btndeleteuser" Runat="server" />
    > >
    > > Thanx!!!

    >
    >
     
    Chris, Jun 17, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. kai
    Replies:
    7
    Views:
    4,989
  2. Microsoft News
    Replies:
    2
    Views:
    1,121
    Microsoft News
    Jan 27, 2005
  3. Alan Silver
    Replies:
    2
    Views:
    542
    Alan Silver
    Jul 12, 2005
  4. Meir
    Replies:
    1
    Views:
    3,497
    David Potts
    Jun 29, 2003
  5. JP

    Pop-up Message Box

    JP, May 3, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    3
    Views:
    168
Loading...

Share This Page