Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. How to make a alert box on Button click

How to make a alert box on Button click

Scheduled Pinned Locked Moved ASP.NET
tutorial
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Balwan
    wrote on last edited by
    #1

    How to make a alert box on Button click:omg: Balwan Singh

    S R 2 Replies Last reply
    0
    • B Balwan

      How to make a alert box on Button click:omg: Balwan Singh

      S Offline
      S Offline
      Sheel Gohe
      wrote on last edited by
      #2

      try: response.write("alert('Hello!');") Sheel Gohe

      B 1 Reply Last reply
      0
      • S Sheel Gohe

        try: response.write("alert('Hello!');") Sheel Gohe

        B Offline
        B Offline
        Balwan
        wrote on last edited by
        #3

        I have to check textbox that it is not null if null while clicking the butoon then a alert box appear with a message is that you have not entered anything?:confused: Balwan Singh

        1 Reply Last reply
        0
        • B Balwan

          How to make a alert box on Button click:omg: Balwan Singh

          R Offline
          R Offline
          R Prabha Devi
          wrote on last edited by
          #4

          Hi, On click of the button call a javascript method in code behind, Below is .aspx.cs page code: For eg : Let server control button id be 'btnSave'

          btnSave.Attributes.Add("OnClick","javascript:return ValidateTextBox();");

          .aspx page code :

          function ValidateTextBox()
          {
          //for eg:let the textbox id be 'txtName'

          //First check whether the textbox exists
          if(document.getElementById("txtName")!=null)
          {
          if(isEmptyCheck("txtName")==true)
          {
          alert("Text box value is empty,please enter value");
          return false;
          }
          }
          }

          //function to check whether text box value is empty or not

          function isEmptyCheck(X)
          {
          if((document.forms[0].elements[X].value=="") || (document.forms[0].elements[X].value.substring(0,1) == ' '))
          {
          return true;
          }
          return false;
          }//end of function

          Hope this helps you... :)

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups