ASP.net Javascript Error htmlfile: not implemented

D

damonl73

Hi. I'm relatively new to asp.net and very new to javascript. I'm
attempting to modify table cells after my page has loaded. Here is the
javascript code within my asp.net page which runs OnLoad:

<script language="javascript">
function ShowGridHeader()
{
if (typeof grdData == "undefined")
{
alert("undefined")
}
else
{
alert("defined")
var rgWidths = new Array();
------> tblDataHeader.rows[0].cells.length =
grdData.rows[0].cells.length;
for (var i = 0; i < grdData.rows[0].cells.length; i++)
{
tblDataHeader.rows[0].cells = grdData.rows[0].cells;
rgWidths = grdData.rows[0].cells.offsetWidth;
}
}
}
</script>

I'm getting an "htmlfile: not implemented" error. It gives me the
alert box and then fails on the line I indicated with an arrow. I have
been unable to find any documentation of this error. Anyone have any
suggestions?

Thanks,
D
 
J

Juan T. Llibre

Are you using RegisterStartupScript
or RegisterClientScriptBlock ?



Juan T. Llibre
ASP.NET MVP
===========
 
D

damonl73

No, I'm not. I will look into they're usage, as I am not familiar with
them. Thanks.
 
D

damonl73

If by not using RegisterStartupScript
or RegisterClientScriptBlock would it execute my script at all? It
starts to execute the scripts gives a run-time error when I try to set
...cells.length.
 
R

RobG

Hi. I'm relatively new to asp.net and very new to javascript. I'm
attempting to modify table cells after my page has loaded.

Then ASP is irrelevant. Just discuss the code at the client, how you
generate it at the server is for some other forum.
Here is the
javascript code within my asp.net page which runs OnLoad:

<script language="javascript">

language has been depreciated, use:

function ShowGridHeader()
{
if (typeof grdData == "undefined")
{
alert("undefined")
}

This script does not define grdData anywhere, so it is undefined. Your
script will stop execution right there - at least that is what the
code instructs the browser to do and what both IE and Firefox did for
me.
else
{
alert("defined")
var rgWidths = new Array();
------> tblDataHeader.rows[0].cells.length =
grdData.rows[0].cells.length;

You can't set 'length'. It's like telling a tree how many apples
it has. ...cells.length will return the number of cells in a row (IE
will also return the number of cells in a table if asked), are you
trying to use it to tell the row to create that number of cells?

If so, this is not how to do it. Learn about document.createElement.

Where have you defined "tblDataHeader"? It seems to be a reference to
a table header (thead) element, but ... ?

To get a reference to an HTML element, give it an id, then get a
reference to it. Suppose your HTML looks like:

<table id="tblDataTable">
<thead id="tblDataHeader">
<tr onclick="alert(this.cells.length);">
<td>blah1</td>
<td>blah2</td>
</tr>
</thead>
<tbody>
<tr><td>&nbsp;</td><td>&nbsp;</td></tr>
</tbody>
</table>

You can get a reference to the thead by:

var tbleDataHeader;
if ( document.getElementById ) {
tbleDataHeader = document.getElementById('tblDataHeader')
} else if (document.all) {
tbleDataHeader = document.all['tblDataHeader'];
}

If you are trying to create an element (say a table element), use:

var elementRef = document.createElement('table');

I think it would be best if you say what you are trying to achieve,
since your script is pretty broken it's impossible to tell what you are
trying to do.
 
D

damonl73

All objects are declared elsewhere. In the debugger I can see the
values of all objects listed, so I know that is not my problem. What
I'm trying to do is dynamically format the tblDataHeader table. I was
attempting to set the length in order to set the number of columns in
the table. The ultimate goal here is to get a data grid with a
scrollable detail and fixed headers. Thanks.
 
Joined
May 2, 2008
Messages
1
Reaction score
0
damonl73,

From what I understand of your issue, I had a similar problem when attempting to call a local function from a Web Service callback handler, such that the following code (which gets some data from a Web Service before allowing a drag'n'drop operation) would produce the error you mention:

function ServiceCallSucceeded(response, userContext, methodName) {
if (methodName == "ObjectClicked") {
document.onmousemove = DragObject(userContext);
document.onmouseup = DropObject(userContext);
}
}

In my case, the resolution to this issue was to encapsulate the function calls in new inline functions as follows:

function ServiceCallSucceeded(response, userContext, methodName) {
if (methodName == "ObjectClicked") {
document.onmousemove = function() { DragObject(userContext); }
document.onmouseup = function() { DropObject(userContext); }
}
}

The callback handler is now able to call local functions 'DragObject' and 'DropObject' without producing the 'htmlfile: not implemented' error.

I hope this helps someone, even though this thread is 3 years old!

- T
 

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,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top