You must Sign In to post a response.
  • Category: .NET

    Javascript message box in asp.net

    Please check the below code

    <asp:Button ID="cmdclacu" OnClientClick= "confirm_meth()" style="position:absolute; left: 759px; top: 593px;" runat="server" Text="Calculate" Width="141px" />

    Javscript code for the button

    <script language="javascript" type="text/javascript">
    function confirm_meth()
    {
    if( confirm("Do you want to continue!Click 'YES'")==true)
    {
    returnvalue()
    }
    else
    {
    document.writeln ("<b>You clicked on 'NO' Button</b>");
    }
    }
    function returnvalue()
    {
    Dim temptot As Double
    temptot = Val(Msfg.FooterRow.Cells(2).Text) - Val(Msfg1.FooterRow.Cells(2).Text)
    txtname.text = temptot
    return false
    }
    </script>


    This is not working. When the button is clicked, nothing happens
  • #652788
    replace OnClientClick= "confirm_meth()" with
    OnClientClick= "return confirm_meth()"

    This will help you

  • #652789
    Script itself is wrong. You have Javascript and VBScript merged together. You have specified it as javascript in the script tag and you are using VBScript like given below which is not valid. Please convert all the Javascript and try again.

    Dim temptot As Double
    temptot = Val(Msfg.FooterRow.Cells(2).Text) - Val(Msfg1.FooterRow.Cells(2).Text)

    Regards,
    Venkatarajan A

    BEEN THERE. DESTROYED THAT.

  • #652791
    Hi,


    1. Please check "returnvalue()" function, your code not like javascript code.

    2. Change the code when call function, Return value from "returnvalue()" function does not affect directly. so you need to get in a boolean variable and return or use this code.

    return returnvalue();

    SQL Server Programmers and Consultants

  • #652792
    Hello,

    Use below java script message box.


    <script type="text/javascript">
    function doYesNo(){
    doIt=confirm('do you wish to proceed?');
    if(doIt){
    alert("Yes");//Your Logic here
    }
    else{
    alert("No"); //Your Logic here
    }
    }
    </script>



    <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="return doYesNo()"/>

    Regards,
    Naveen

  • #652799
    Please change this as


    <asp:Button ID="cmdclacu" OnClick= "Javascript:return confirm('Are You sure');" style="position:absolute; left: 759px; top: 593px;" runat="server" Text="Calculate" Width="141px" />

    Thanks & Regards
    Anil Kumar Pandey
    Microsoft MVP, DNS MVM


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.