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. JQuery unable to find controls on a page [modified]

JQuery unable to find controls on a page [modified]

Scheduled Pinned Locked Moved ASP.NET
helpquestioncsharpjavascriptvisual-studio
8 Posts 2 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
    AndyASPVB
    wrote on last edited by
    #1

    Hi I have a JQuery date mask, but when I run the page it throws an error "Microsoft JScript runtime error: Object doesn't support this property or method". Now, the control that this particular JQuery is meant to be working is added dynamically to a repeater control. Through this, I have looked at the ids of the control, where it was breaking and stopping in Visual Studio and what is being shown on the aspx page. The ids are identical except of the "#" that JQuery has at the start, which is not on the page. In my JQuery code I have: JQuery(function ($) { $('#<%=date.ClientID %>').mask("99/99/9999"); }); Is there away to tell JQuery not to include the "#" when finding the control? I have used UniqueID but this changes any underscore into "$", which is not the same as what is on the page. My only problem is with "#" sign at the start of the ID. I have even added an alert box to check that textbox was there and it came back as null. I have tried even adding a CssClass attribute to the textbox, but this through the same error, too. Please note that the custom user control that has the textbox is added programatically to the repeater. Can anyone help? Thanks

    modified on Saturday, December 4, 2010 4:21 AM

    N 1 Reply Last reply
    0
    • A AndyASPVB

      Hi I have a JQuery date mask, but when I run the page it throws an error "Microsoft JScript runtime error: Object doesn't support this property or method". Now, the control that this particular JQuery is meant to be working is added dynamically to a repeater control. Through this, I have looked at the ids of the control, where it was breaking and stopping in Visual Studio and what is being shown on the aspx page. The ids are identical except of the "#" that JQuery has at the start, which is not on the page. In my JQuery code I have: JQuery(function ($) { $('#<%=date.ClientID %>').mask("99/99/9999"); }); Is there away to tell JQuery not to include the "#" when finding the control? I have used UniqueID but this changes any underscore into "$", which is not the same as what is on the page. My only problem is with "#" sign at the start of the ID. I have even added an alert box to check that textbox was there and it came back as null. I have tried even adding a CssClass attribute to the textbox, but this through the same error, too. Please note that the custom user control that has the textbox is added programatically to the repeater. Can anyone help? Thanks

      modified on Saturday, December 4, 2010 4:21 AM

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      No you can't eliminate the #, its how JQuery identifies element IDs. It sounds as though the getting the element isn't the problem, its the mask function. Are you sure you have included the proper javascript links on your page?


      I know the language. I've read a book. - _Madmatt

      A 1 Reply Last reply
      0
      • N Not Active

        No you can't eliminate the #, its how JQuery identifies element IDs. It sounds as though the getting the element isn't the problem, its the mask function. Are you sure you have included the proper javascript links on your page?


        I know the language. I've read a book. - _Madmatt

        A Offline
        A Offline
        AndyASPVB
        wrote on last edited by
        #3

        This is how I have the code set up on the control, as you can see I have the JQuery function commented until I can understand and solve what is going wrong! <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="MaskControl.ascx.cs" Inherits="Prototype.CommonControls.MaskControl" > </x-turndown>

        N 1 Reply Last reply
        0
        • A AndyASPVB

          This is how I have the code set up on the control, as you can see I have the JQuery function commented until I can understand and solve what is going wrong! <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="MaskControl.ascx.cs" Inherits="Prototype.CommonControls.MaskControl" > </x-turndown>

          N Offline
          N Offline
          Not Active
          wrote on last edited by
          #4

          And $('.dateMask') is a valid element? Have you tried

          $(document).ready()
          {
          $('.dateMask').mask("99/99/9999");
          });

          It doesn't have anything to do with the problem but you should place the javascript in a seperate file rather than in the control. It will improve the maintainability of your code.


          I know the language. I've read a book. - _Madmatt

          A 1 Reply Last reply
          0
          • N Not Active

            And $('.dateMask') is a valid element? Have you tried

            $(document).ready()
            {
            $('.dateMask').mask("99/99/9999");
            });

            It doesn't have anything to do with the problem but you should place the javascript in a seperate file rather than in the control. It will improve the maintainability of your code.


            I know the language. I've read a book. - _Madmatt

            A Offline
            A Offline
            AndyASPVB
            wrote on last edited by
            #5

            The code I am using is from a website called "http://digitalbush.com/projects/masked-input-plugin" and I followed was given on the site. As shown below: JQuery(function ($) { $('#<%=date.ClientID %>;').mask("99/99/9999"); }); When I followed the example given on the website, all I was getting is the Microsoft JScript error message. Then I have tried all various ways with CssClass. I will try the example you have given, but I can't try it until Monday. Should it not work, what other advice can you give for me to try?

            N 1 Reply Last reply
            0
            • A AndyASPVB

              The code I am using is from a website called "http://digitalbush.com/projects/masked-input-plugin" and I followed was given on the site. As shown below: JQuery(function ($) { $('#<%=date.ClientID %>;').mask("99/99/9999"); }); When I followed the example given on the website, all I was getting is the Microsoft JScript error message. Then I have tried all various ways with CssClass. I will try the example you have given, but I can't try it until Monday. Should it not work, what other advice can you give for me to try?

              N Offline
              N Offline
              Not Active
              wrote on last edited by
              #6

              That is the problem with just copying code without understanding it.


              I know the language. I've read a book. - _Madmatt

              A 1 Reply Last reply
              0
              • N Not Active

                That is the problem with just copying code without understanding it.


                I know the language. I've read a book. - _Madmatt

                A Offline
                A Offline
                AndyASPVB
                wrote on last edited by
                #7

                Hi Well, I applied the following code, and added some more: $(document).ready() { $('.dateMask').mask("99/99/9999"); }); To check that JQuery was picking up the ids of the control, I added $('input[class$=dateMask]') and sent the output to an alert box. Thankfully JQuery found the control by class, but fell over when applying the mask. So, the problem lies with the plugin!

                N 1 Reply Last reply
                0
                • A AndyASPVB

                  Hi Well, I applied the following code, and added some more: $(document).ready() { $('.dateMask').mask("99/99/9999"); }); To check that JQuery was picking up the ids of the control, I added $('input[class$=dateMask]') and sent the output to an alert box. Thankfully JQuery found the control by class, but fell over when applying the mask. So, the problem lies with the plugin!

                  N Offline
                  N Offline
                  Not Active
                  wrote on last edited by
                  #8

                  Alert boxes are not debugging tools. You have the source, set a break point and debug.


                  I know the language. I've read a book. - _Madmatt

                  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