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. Javascript function in a web usercontrol

Javascript function in a web usercontrol

Scheduled Pinned Locked Moved ASP.NET
javascriptquestion
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.
  • A Offline
    A Offline
    anujose
    wrote on last edited by
    #1

    i am creating a usercontrol that contains 2 textboxes and a button.textboxes are web controls .i want to check when i click in button whether textboxes contains value or not? is it possible to write a javascript function inside a usercontrol? i tried if(document.getElementById('Name').value=="") { alert("Name can't be empty"); } but it's not working? with regards, Anu

    N V 2 Replies Last reply
    0
    • A anujose

      i am creating a usercontrol that contains 2 textboxes and a button.textboxes are web controls .i want to check when i click in button whether textboxes contains value or not? is it possible to write a javascript function inside a usercontrol? i tried if(document.getElementById('Name').value=="") { alert("Name can't be empty"); } but it's not working? with regards, Anu

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      anujose wrote:

      if(document.getElementById('Name').value=="")

      You will get error on this line, if control Name is a server control. This happens because ASP.NET appends user control name with the server side controls to make control id unique. So you need to view source of the page and find out how your control is rendered. Usually it will be like usercontrolname_controlname. Find this name and use that in javascript.


      My Website | Ask smart questions

      1 Reply Last reply
      0
      • A anujose

        i am creating a usercontrol that contains 2 textboxes and a button.textboxes are web controls .i want to check when i click in button whether textboxes contains value or not? is it possible to write a javascript function inside a usercontrol? i tried if(document.getElementById('Name').value=="") { alert("Name can't be empty"); } but it's not working? with regards, Anu

        V Offline
        V Offline
        Vasudevan Deepak Kumar
        wrote on last edited by
        #3

        anujose wrote:

        'Name'

        '<%=Name.ClientID%>'

        Vasudevan Deepak Kumar Personal Homepage Tech Gossips

        A 1 Reply Last reply
        0
        • V Vasudevan Deepak Kumar

          anujose wrote:

          'Name'

          '<%=Name.ClientID%>'

          Vasudevan Deepak Kumar Personal Homepage Tech Gossips

          A Offline
          A Offline
          anujose
          wrote on last edited by
          #4

          can you just explain?

          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