OBJECT EXPECTED ERROR.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jc

    OBJECT EXPECTED ERROR.

    I'm trying the below and getting OBJECT EXPECTED error in
    javascript.

    On my aspx page I have this java script block:


    <script language="javas cript" type="text/javascript">
    function SearchText(sele ctit)
    {
    document.getEle mentById('TextB ox_Body').creat eTextRange().fi nd(selectit);
    }
    </script>

    In vb.net I'm dynamically generate javascript

    <script language='JavaS cript'>
    SearchText('car ');
    </script>

    using this code and passing it the string "car":

    Public Function SelectText(ByVa l SearchString As String) As String
    Return "<script language='JavaS cript'>" + vbCrLf +
    "SearchText ('" + SearchString + "');" + vbCrLf + "</script>"
    End Function

    I force that block to run as follows and I understand this is not
    javascript, but the problem appears to be with my rendered code. Below
    is how I pass :

    ClientScript.Re gisterClientScr iptBlock(Me.Get Type, "client",
    pkb.SelectText( TextBox_Search1 .Text))




    Thanks for any help or information.
  • VK

    #2
    Re: OBJECT EXPECTED ERROR.

    On Jun 19, 10:22 pm, jc <wild...@noclie nt.netwrote:
     I'm trying the below and getting OBJECT EXPECTED error in
    javascript.
    >
    On my aspx page I have this java script block:
    >
    <script language="javas cript" type="text/javascript">
    function SearchText(sele ctit)
    {
    document.getEle mentById('TextB ox_Body').creat eTextRange().fi nd(selectit);}
    >
    </script>
    >
    In vb.net I'm dynamically generate javascript
    >
    <script language='JavaS cript'>
    SearchText('car ');
    </script>
    >
    using this code and passing it the string "car":
    >
     Public Function SelectText(ByVa l SearchString As String) As String
                Return "<script language='JavaS cript'>" + vbCrLf +
    "SearchText ('" + SearchString + "');" + vbCrLf + "</script>"
     End Function
    >
    I force that block to run as follows and I understand this is not
    javascript, but the problem appears to be with my rendered code. Below
    is how I pass :
    >
    ClientScript.Re gisterClientScr iptBlock(Me.Get Type, "client",
    pkb.SelectText( TextBox_Search1 .Text))
    >
    Thanks for any help or information.
    What you are doing server-side is irrelevant to client side: these are
    two absolutely unrelated processes. To see the source of the error
    generate the output page which gives you the error, select View >
    Source (if IE), copy-paste here. If the page is too big or contains a
    sensitive information then you may have to make a separate minimum
    case still demonstrating your problem.

    Comment

    • jc

      #3
      Re: OBJECT EXPECTED ERROR.

      sorry.. let me simplify. for some reason my serverside drops the
      javascript block inside the form block.. i don't think this is the
      problem, but here a simple test that is also failing.

      The original source:

      <html>
      <head>
      <title>
      Javascript testing
      </title>
      </head>

      <body>

      <form name="form1" method="post" action="_Blank" id="form1">


      <script language="javaS cript" type="text/javascript">
      SearchText("tes t");
      </script>


      <input name="TextBox_B ody" type="text" value="this is a test"
      id="TextBox_Bod y" />
      </form>


      <script language="javas cript" type="text/javascript">
      function SearchText(sele ctit)
      {
      document.getEle mentById('TextB ox_Body').creat eTextRange().fi nd(selectit);
      }
      </script>


      </body>
      </html>

      ... a view source places it back on the bottom

      <html>
      <head>
      <title>
      Javascript testing
      </title>
      </head>

      <body>

      <form name="form1" method="post" action="_Blank" id="form1">


      <input name="TextBox_B ody" type="text" value="this is a test"
      id="TextBox_Bod y" />
      </form>


      <script language="javas cript" type="text/javascript">
      function SearchText(sele ctit)
      {
      document.getEle mentById('TextB ox_Body').creat eTextRange().fi nd(selectit);
      }
      </script>

      <script language="javaS cript" type="text/javascript">
      SearchText("tes t");
      </script>



      </body>
      </html>


      giving me the object expected on line 20

      document.getEle mentById('TextB ox_Body').creat eTextRange().fi nd(selectit);

      Comment

      Working...