How To Use JavaScript alert in Visual Studio 2005 in Button?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sagar jivnani
    New Member
    • Jan 2011
    • 1

    How To Use JavaScript alert in Visual Studio 2005 in Button?

    How To Use JavaScript alert in Visual Studio 2005 in Button?

    Please i hope you have an answer for me

    Thanks.
    Last edited by Frinavale; Feb 17 '11, 02:16 PM. Reason: Added the question posted in the title into the thread.
  • yarbrough40
    Contributor
    • Jun 2009
    • 320

    #2
    OnClientClick()
    or
    Attributes.Add( )

    Comment

    • bhuvaneswaran
      New Member
      • Feb 2011
      • 3

      #3
      --------------------------------------------
      first method



      code behaind code

      Code:
      protected void Page_Load(object sender, EventArgs e)
      {
       myButton.Attributes.Add("onClick", "return btnValidate();");
      }


      source page Code
      Code:
      	<script language="javascript" type="text/javascript">
       function validate()
      		{
      
      alert("Welcome");
      
      }
      
      </script>
      --------------------------------------------------

      Second Method



      Code:
      protected void Button1_Click(object sender, EventArgs e)
          {
              Page.ClientScript.RegisterStartupScript(this.GetType(), "err_msg", "alert('Welcome');", true);
          }
      Last edited by Frinavale; Feb 17 '11, 02:17 PM. Reason: Please post code in code tags.

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        Please review the article about How to use JavaScript in ASP.NET.

        -Frinny

        Comment

        Working...