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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Javascript Error: "Object Required" [modified]

Javascript Error: "Object Required" [modified]

Scheduled Pinned Locked Moved ASP.NET
helpjavajavascripthtmlcss
14 Posts 5 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.
  • Q Qasim1984

    hi I have a freetextbox, a hiddenfield and a button on my web page. By pressing the button it insert the text from hiddenfield into freetextbox at current cursor position. I am doing this task using java script. when I run the webpage it give me Object required error. The code is given below //Javascript Code // HTML Code <FTB:FreeTextBox id="FreeTextBox1" toolbarlayout="ParagraphMenu,FontFacesMenu,FontSizesMenu, FontForeColorsMenu,FontForeColorPicker,FontBackColorsMenu, runat="Server" DesignModeCss="designmode.css"/>; <asp:HiddenField ID="HiddenField1" runat="server" />; <asp:Button ID="btnInsert" Text="Insert Text" CssClass="button" runat="server" />; I have registered the click event on pageload protected void Page_Load(object sender, EventArgs e) { HiddenField1.Value = Guid.NewGuid().ToString(); btnInsert.Attributes.Add("onClick", "Show()"); } When I run this page it give me error "Object required" Object required FormBuilder.aspx, line 644 character 29 Please help me <div class="ForumMod">modified on Wednesday, June 24, 2009 5:35 AM</div></x-turndown>

    B Offline
    B Offline
    Baran M
    wrote on last edited by
    #3

    Member 3374813 wrote:

    var ctrl = document.getElementById("txtTargetText");

    Member 3374813 wrote:

    ange.text = document.getElementById("txtSourceText").value; document.getElementById("txtTargetText").focus();

    Hope you have above elements in HTML code. If you have describe it more.

    Education is not a way to escape poverty — it is a way of fighting it.

    Q 1 Reply Last reply
    0
    • Q Qasim1984

      hi I have a freetextbox, a hiddenfield and a button on my web page. By pressing the button it insert the text from hiddenfield into freetextbox at current cursor position. I am doing this task using java script. when I run the webpage it give me Object required error. The code is given below //Javascript Code // HTML Code <FTB:FreeTextBox id="FreeTextBox1" toolbarlayout="ParagraphMenu,FontFacesMenu,FontSizesMenu, FontForeColorsMenu,FontForeColorPicker,FontBackColorsMenu, runat="Server" DesignModeCss="designmode.css"/>; <asp:HiddenField ID="HiddenField1" runat="server" />; <asp:Button ID="btnInsert" Text="Insert Text" CssClass="button" runat="server" />; I have registered the click event on pageload protected void Page_Load(object sender, EventArgs e) { HiddenField1.Value = Guid.NewGuid().ToString(); btnInsert.Attributes.Add("onClick", "Show()"); } When I run this page it give me error "Object required" Object required FormBuilder.aspx, line 644 character 29 Please help me <div class="ForumMod">modified on Wednesday, June 24, 2009 5:35 AM</div></x-turndown>

      H Offline
      H Offline
      himanshu2561
      wrote on last edited by
      #4

      Member 3374813 wrote:

      var ctrl = document.getElementById("txtTargetText");

      where is txtTargetText in your source code?

      himanshu

      1 Reply Last reply
      0
      • C Christian Graus

        Member 3374813 wrote:

        Object required FormBuilder.aspx, line 644 character 29

        Well, how about telling use what line 644 is ? When do you get this error ? What have you done to debug it ?

        Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp

        Q Offline
        Q Offline
        Qasim1984
        wrote on last edited by
        #5

        When I press the button ("btnInsert") Jscript Debbuger gives me this error on the javascript code statement " var saveText = ctrl.value; " on the line 644 with yellow highlighted.

        C 1 Reply Last reply
        0
        • B Baran M

          Member 3374813 wrote:

          var ctrl = document.getElementById("txtTargetText");

          Member 3374813 wrote:

          ange.text = document.getElementById("txtSourceText").value; document.getElementById("txtTargetText").focus();

          Hope you have above elements in HTML code. If you have describe it more.

          Education is not a way to escape poverty — it is a way of fighting it.

          Q Offline
          Q Offline
          Qasim1984
          wrote on last edited by
          #6

          Sorry I have posted old html txtsourceText is id of HiddenField i.e HiddenField1 in html txtTargetText is id of FreeTextBox i.e FreeTextBox1 in html

          B 1 Reply Last reply
          0
          • Q Qasim1984

            Sorry I have posted old html txtsourceText is id of HiddenField i.e HiddenField1 in html txtTargetText is id of FreeTextBox i.e FreeTextBox1 in html

            B Offline
            B Offline
            Baran M
            wrote on last edited by
            #7

            Post your new code or modify the existing one plz :)

            Education is not a way to escape poverty — it is a way of fighting it.

            Q 1 Reply Last reply
            0
            • B Baran M

              Post your new code or modify the existing one plz :)

              Education is not a way to escape poverty — it is a way of fighting it.

              Q Offline
              Q Offline
              Qasim1984
              wrote on last edited by
              #8

              I have modified the javascript code as I have currently on my side. It is now correct. I am waiting your help please.

              B 1 Reply Last reply
              0
              • Q Qasim1984

                When I press the button ("btnInsert") Jscript Debbuger gives me this error on the javascript code statement " var saveText = ctrl.value; " on the line 644 with yellow highlighted.

                C Offline
                C Offline
                Christian Graus
                wrote on last edited by
                #9

                ctrl is therefore null. So, I assume that means you're setting it with document.getElementById, and not checking the return value. Odds are that you're using the server side ids instead of using the clientId property to get the client side id's for your script.

                Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp

                Q 1 Reply Last reply
                0
                • C Christian Graus

                  ctrl is therefore null. So, I assume that means you're setting it with document.getElementById, and not checking the return value. Odds are that you're using the server side ids instead of using the clientId property to get the client side id's for your script.

                  Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp

                  Q Offline
                  Q Offline
                  Qasim1984
                  wrote on last edited by
                  #10

                  I am new to Javascript How I can get Client Side Id in javascript code please Client side Id for FreeTextBox1 and HiddenField1?

                  1 Reply Last reply
                  0
                  • Q Qasim1984

                    I have modified the javascript code as I have currently on my side. It is now correct. I am waiting your help please.

                    B Offline
                    B Offline
                    Baran M
                    wrote on last edited by
                    #11

                    Which browser are you using ? It works fine in IE but firefox. It seems detecting text selection in firefox[^] is different. It may fail because of this reason.

                    Education is not a way to escape poverty — it is a way of fighting it.

                    1 Reply Last reply
                    0
                    • Q Qasim1984

                      hi I have a freetextbox, a hiddenfield and a button on my web page. By pressing the button it insert the text from hiddenfield into freetextbox at current cursor position. I am doing this task using java script. when I run the webpage it give me Object required error. The code is given below //Javascript Code // HTML Code <FTB:FreeTextBox id="FreeTextBox1" toolbarlayout="ParagraphMenu,FontFacesMenu,FontSizesMenu, FontForeColorsMenu,FontForeColorPicker,FontBackColorsMenu, runat="Server" DesignModeCss="designmode.css"/>; <asp:HiddenField ID="HiddenField1" runat="server" />; <asp:Button ID="btnInsert" Text="Insert Text" CssClass="button" runat="server" />; I have registered the click event on pageload protected void Page_Load(object sender, EventArgs e) { HiddenField1.Value = Guid.NewGuid().ToString(); btnInsert.Attributes.Add("onClick", "Show()"); } When I run this page it give me error "Object required" Object required FormBuilder.aspx, line 644 character 29 Please help me <div class="ForumMod">modified on Wednesday, June 24, 2009 5:35 AM</div></x-turndown>

                      C Offline
                      C Offline
                      Chetan visodiya
                      wrote on last edited by
                      #12

                      Replace first line of show function with below code var ctrl = document.getElementById('<%=FreeTextBox1.ClientID%>'); It might help you.

                      Q 1 Reply Last reply
                      0
                      • C Chetan visodiya

                        Replace first line of show function with below code var ctrl = document.getElementById('<%=FreeTextBox1.ClientID%>'); It might help you.

                        Q Offline
                        Q Offline
                        Qasim1984
                        wrote on last edited by
                        #13

                        Thank you very much. I have received this error message on the next line of my javascript code Error: Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus. FormBuilder.aspx, line 651 character 9 Line of Code: ctrl.focus();

                        C 1 Reply Last reply
                        0
                        • Q Qasim1984

                          Thank you very much. I have received this error message on the next line of my javascript code Error: Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus. FormBuilder.aspx, line 651 character 9 Line of Code: ctrl.focus();

                          C Offline
                          C Offline
                          Chetan visodiya
                          wrote on last edited by
                          #14

                          Make sure that your text box control(FreeTextBox1) is enabled and visible. if not then first enable it then set the focus otherwise it gives an error.

                          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