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. Alert Box

Alert Box

Scheduled Pinned Locked Moved ASP.NET
4 Posts 4 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

    I have to check a textbox text and if it is null while clicking the button then i have to show a message on alert box.:confused: Balwan Singh

    K R C 3 Replies Last reply
    0
    • B Balwan

      I have to check a textbox text and if it is null while clicking the button then i have to show a message on alert box.:confused: Balwan Singh

      K Offline
      K Offline
      kirthikirthi
      wrote on last edited by
      #2

      Write a javascript function And call the function on button click function script() Dim s As String "alert('')" RegisterStartupScript("", s) end function If textbox = "" then Do stuff else script() endif asdfasdfasdfasdfasdfasdfasdfasdfasdfasdf -- modified at 5:32 Monday 1st May, 2006

      1 Reply Last reply
      0
      • B Balwan

        I have to check a textbox text and if it is null while clicking the button then i have to show a message on alert box.:confused: Balwan Singh

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

        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
        • B Balwan

          I have to check a textbox text and if it is null while clicking the button then i have to show a message on alert box.:confused: Balwan Singh

          C Offline
          C Offline
          CWIZO
          wrote on last edited by
          #4

          Use the RequierdFieldValidator control ;) -------------------------------------------------------- My portfolio & development blog Q:What does the derived class in C# tell to it's parent? A:All your base are belong to us!

          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