confirm message using "Alert"

Last post 07-04-2009 9:55 AM by Beaudeep. 8 replies.

Sort Posts:

  • confirm message using "Alert"

    07-03-2009, 8:22 PM
    • Member
      19 point Member
    • Beaudeep
    • Member since 12-03-2008, 1:57 AM
    • Posts 8

    Hi everyone..

     I want to know how can I use confirm message "Yes - No"  for example "when I want to delete" by using Alert

    cause with MsgBox it needs to install framework in client ...


    thank you

  • Re: confirm message using "Alert"

    07-03-2009, 10:23 PM
    Answer
    • Member
      437 point Member
    • jewelhere
    • Member since 01-18-2009, 6:55 AM
    • Dhaka, Bangladesh
    • Posts 110

    use OnClientClick="return fnConfirm()" in button.

    write a function name:

    and write this:

    <script language="javascript" type="text/javascript">
            function fnConfirm()
            {
                return confirm("Are you sure?");           
            }
            
        
        </script>


    please mark as answer if this helps u

  • Re: confirm message using "Alert"

    07-03-2009, 10:24 PM
    Answer
    • All-Star
      24,074 point All-Star
    • PeteNet
    • Member since 01-21-2009, 1:15 PM
    • Posts 3,406

    there are multiple ways to do it, also depends on where and which control will fire it...take a look here for your options: http://forums.asp.net/p/1433767/3223533.aspx#3223533

    basically, the javascript "return confirm('Are you sure you want to delete?')" will do it ...you can use it inline or do a .Attributes.Add in the codebehind


    Regards,
    Peter
  • Re: confirm message using "Alert"

    07-04-2009, 12:11 AM
    Answer
    • All-Star
      20,440 point All-Star
    • venkatu2005
    • Member since 07-01-2008, 6:48 AM
    • Posts 4,467

    Beaudeep:
     I want to know how can I use confirm message "Yes - No"  for example "when I want to delete" by using Alert

    <asp:Button runat="server" ID="DeleteButton" CommandName="Delete" Text="Delete" OnClientClick="return confirm('Are you sure you want to delete this record?');" />

    I have Changed My Blog from (http://venkat-dotnetsamples.blogspot.com) to (http://venkat-dotnetsnippets.blogspot.com)

    Regards,
    Venkatesan.M

    Please Mark as Answered If its helpful and Un-Mark as Answered if it not help u.
  • Re: confirm message using "Alert"

    07-04-2009, 12:43 AM
    Answer

    <asp:Button ID="btnDelete" runat="server" Text="Delete" OnClientClick="javascript:return confirmation();" />

    <script type="text/javascript">  

    function confirmation()

    {

    confirm('Are you aure want to delete?')

    if ('yes')

    {return true; // postback occures here

    }

     else {return false;

    }

    </script>

     

    Regards,
    Ram Reddy Mekha, +91-994-840-4315
    http://abhiramreddymekha.blogspot.com

    Please Mark as Answer if the post helps you.
  • Re: confirm message using "Alert"

    07-04-2009, 8:56 AM
    • Member
      19 point Member
    • Beaudeep
    • Member since 12-03-2008, 1:57 AM
    • Posts 8

    thanks guys...

    How if I want to use alert after condition ...like:


    Protected Sub DeleteButton_Click(ByVal sender As Object, ByVal e......

    ..

    ..

    if textbox1.text = 1 then

    here put alret message

    ..

    ..

    else

    exit sub

    end if

    End Sub


    thank u again





  • Re: confirm message using "Alert"

    07-04-2009, 9:13 AM
    Answer
    • All-Star
      59,087 point All-Star
    • mudassarkhan
    • Member since 02-28-2008, 5:28 AM
    • Mumbai, India
    • Posts 10,469
  • Re: confirm message using "Alert"

    07-04-2009, 9:38 AM
    Answer

    To display normal alert pop up in the code behind:

    ClientScript.RegisterStartupScript(Page.GetType(), "Alert", "alert('Done perfectly.');", true);

    To call a java script function in the code behind:

    ClientScript.RegisterStartupScript(Page.GetType(), "confirmation", "javascript:return confirmation();", true);

    (Ths is to call the confirmation java script function I wrote in my previous post.)

    Regards,
    Ram Reddy Mekha, +91-994-840-4315
    http://abhiramreddymekha.blogspot.com

    Please Mark as Answer if the post helps you.
  • Re: confirm message using "Alert"

    07-04-2009, 9:55 AM
    • Member
      19 point Member
    • Beaudeep
    • Member since 12-03-2008, 1:57 AM
    • Posts 8

    Thank you it works good Laughing

Page 1 of 1 (9 items)