OBJECT EXPECTED ERROR.

J

jc

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

On my aspx page I have this java script block:


<script language="javascript" type="text/javascript">
function SearchText(selectit)
{
document.getElementById('TextBox_Body').createTextRange().find(selectit);
}
</script>

In vb.net I'm dynamically generate javascript

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

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

Public Function SelectText(ByVal SearchString As String) As String
Return "<script language='JavaScript'>" + 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.RegisterClientScriptBlock(Me.GetType, "client",
pkb.SelectText(TextBox_Search1.Text))




Thanks for any help or information.
 
V

VK

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

On my aspx page I have this java script block:

<script language="javascript" type="text/javascript">
function SearchText(selectit)
{
document.getElementById('TextBox_Body').createTextRange().find(selectit);}

</script>

In vb.net I'm dynamically generate javascript

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

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

 Public Function SelectText(ByVal SearchString As String) As String
            Return "<script language='JavaScript'>" + 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.RegisterClientScriptBlock(Me.GetType, "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.
 
J

jc

True. Thanks. What's the best way to troubleshoot javascript?



getting the error on this line:

SearchText('car');



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head><link href="App_Themes/xxx/xxx.css" type="text/css"
rel="stylesheet" /><title>
Untitled Page
</title><style type="text/css">
.Menu_0 { background-
color:white;visibility:hidden;display:none;position:absolute;left:
0px;top:0px; }
.Menu_1 { font-family:Helvetica;font-size:Small;text-
decoration:none; }

</style></head>
<body>
<img src="App_Themes/xxx/xxx/xxx.GIF" style="left: 25px; position:
absolute; top: 5px; width: 901px; height: 60px;" id="IMG1"
onclick="return IMG1_onclick()" />
<form name="form1" method="post" action="default.aspx"
onkeypress="javascript:return WebForm_FireDefaultButton(event,
'Submit')" id="form1">
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT"
value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/
wEPDwUKMTIyODc2..." />
</div>

<script type="text/javascript">
<!--
var theForm = document.forms['form1'];
if (!theForm) {
theForm = document.form1;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
// -->
</script>

<script src="/xxx/WebResource.axd?
d=ductVNmLLwTW8qH0DuVO6w2&amp;t=633044950087656250" type="text/
javascript"></script>

<script language='javaScript' type='text/javascript'>
SearchText('car');
</script>
<script src="/pkbdev/WebResource.axd?
d=2ZN5FwKo2eqvua9pkS3VWg2&amp;t=633044950087656250" type="text/
javascript"></script>
<script src="/pkbdev/WebResource.axd?
d=SsFY3QCIOjs2X3fW5QuPOg2&amp;t=633044950087656250" type="text/
javascript"></script>

<div class="data" style="position: absolute;top:95px; left: 26px;
width: 865px; height: 460px;">
Search:<br />
<input name="TextBox_Search1" type="text" value="car"
id="TextBox_Search1" class="textbox" style="width:214px;" />
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
<input name="TextBox_Search2" type="text" id="TextBox_Search2"
class="textbox" style="width:214px;" /><br />
<br />

Title:<br />

</textarea>
<br />
<span id="Label_Message" style="display:inline-block;color:Red;height:
34px;width:651px;"></span>

<input type="submit" name="Submit" value="Button" id="Submit"
style="left: 314px; position: absolute; top: -243px" />

<br />
</div>

<div>
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION"
value="/wEWDIMAvWajYsPArzDhLYEBEe+jG2EsEFIIt59O8U1Oz4+h7k=" />
</div>

<script type="text/javascript">
<!--
var Menu_Data = new Object();
Menu_Data.disappearAfter = 500;
WebForm_AutoFocus('TextBox_Search1');// -->
</script>
</form>


<script language="javascript" type="text/javascript">
function SearchText(selectit)
{
document.getElementById('TextBox_Body').createTextRange().find(selectit);
}

</script>

</body>
</html>
 
J

jc

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="javaScript" type="text/javascript">
SearchText("test");
</script>


<input name="TextBox_Body" type="text" value="this is a test"
id="TextBox_Body" />
</form>


<script language="javascript" type="text/javascript">
function SearchText(selectit)
{
document.getElementById('TextBox_Body').createTextRange().find(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_Body" type="text" value="this is a test"
id="TextBox_Body" />
</form>


<script language="javascript" type="text/javascript">
function SearchText(selectit)
{
document.getElementById('TextBox_Body').createTextRange().find(selectit);
}
</script>

<script language="javaScript" type="text/javascript">
SearchText("test");
</script>



</body>
</html>


giving me the object expected on line 20

document.getElementById('TextBox_Body').createTextRange().find(selectit);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,062
Latest member
OrderKetozenseACV

Latest Threads

Top