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. Reference of WEb Control in the Html Page

Reference of WEb Control in the Html Page

Scheduled Pinned Locked Moved ASP.NET
javascripthtmlhelptutorial
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.
  • P Offline
    P Offline
    payal sheth
    wrote on last edited by
    #1

    Hello all,,, i want to validate my web controls on my aspx pages...but i dont want to use FieldValidators as it is fireing on all the web control buttons i have on that web page. i want to validate the controls by writing Javascript....so it validates atmy client side...like after the head tag in the Html page... function clearControls() { webctrl.text = ""; } then call this Function on the web controls button Click..... My problem is that i am not able to get the reference of the web controls on the html page.... like i m not able to write... document.form1.textbox1.text = "" where textbox1 is as WEb control...same thing i can do for the Html Controls... Let me know how to get the reference... Thanks.... ....................

    C J E 3 Replies Last reply
    0
    • P payal sheth

      Hello all,,, i want to validate my web controls on my aspx pages...but i dont want to use FieldValidators as it is fireing on all the web control buttons i have on that web page. i want to validate the controls by writing Javascript....so it validates atmy client side...like after the head tag in the Html page... function clearControls() { webctrl.text = ""; } then call this Function on the web controls button Click..... My problem is that i am not able to get the reference of the web controls on the html page.... like i m not able to write... document.form1.textbox1.text = "" where textbox1 is as WEb control...same thing i can do for the Html Controls... Let me know how to get the reference... Thanks.... ....................

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      The individual control id will be a concatenation of the custom control id and the id of the contol within the custom control. I think there is an underscore between the two but I don't recall. If you view the source of your page when it is rendered in IE you will see how it is built up.


      Do you want to know more?


      Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.

      1 Reply Last reply
      0
      • P payal sheth

        Hello all,,, i want to validate my web controls on my aspx pages...but i dont want to use FieldValidators as it is fireing on all the web control buttons i have on that web page. i want to validate the controls by writing Javascript....so it validates atmy client side...like after the head tag in the Html page... function clearControls() { webctrl.text = ""; } then call this Function on the web controls button Click..... My problem is that i am not able to get the reference of the web controls on the html page.... like i m not able to write... document.form1.textbox1.text = "" where textbox1 is as WEb control...same thing i can do for the Html Controls... Let me know how to get the reference... Thanks.... ....................

        J Offline
        J Offline
        J4amieC
        wrote on last edited by
        #3

        In addition to the previous answer, the client side javascript property is .value not .text document.form1.textbox1.value = "";

        1 Reply Last reply
        0
        • P payal sheth

          Hello all,,, i want to validate my web controls on my aspx pages...but i dont want to use FieldValidators as it is fireing on all the web control buttons i have on that web page. i want to validate the controls by writing Javascript....so it validates atmy client side...like after the head tag in the Html page... function clearControls() { webctrl.text = ""; } then call this Function on the web controls button Click..... My problem is that i am not able to get the reference of the web controls on the html page.... like i m not able to write... document.form1.textbox1.text = "" where textbox1 is as WEb control...same thing i can do for the Html Controls... Let me know how to get the reference... Thanks.... ....................

          E Offline
          E Offline
          echovault
          wrote on last edited by
          #4

          You can modify the literal control's event's like so:

          btnSubmit.Attributes.Add( "onclick", "setDefaultText( e, 'Default Text', '" + txtTest.ClientID + "' );" );

          View Source:

          on your aspx page or in a .js file:
          function setDefaultText(e, newText, target) {
          var elt = document.getElementById(target);
          elt.value = newText;
          }

          That's the gyst of it. You may have to play around with it a little. Attributes.Add gives you a way to control the attributes of a server control when it is generated by the server. Be careful. You can overwrite attributes that the server may need. For instance submit buttons tend to have a doPostBack Event for the onclick attribute. these can be dealt with, but this will get you started. -- Life's a journey, not a destination

          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