Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > PreRender code seems to cause Javascript error!

Thread Tools

PreRender code seems to cause Javascript error!

Posts: n/a
I'm strictly a high-level programmer, so please excuse my ignorance of
the inner magic of ASP etc.

I have what my company calls a "builder form". It is used to maintain
static lookup lists. It contains a Datagrid control with an Edit
Template specified.

The code behind contains the following function:

Private Sub Page_PreRender(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.PreRender

' If in not edit mode activate row highlighting / click to edit
If Not Editing Then
End If

End Sub

This calls the following two functions:

Public Sub ActivateRowHighlight(ByRef page As Page, Optional ByVal
gridName As String = "dgSearch")

' Inject Jscript to activate row highlight and selection
page.RegisterStartupScript(Guid.NewGuid.ToString, "<script
language=javascript>try{HighlightTableRow('" + gridName +

End Sub

Public Sub ActivateClicktoEdit(ByRef page As Page, Optional ByVal
gridName As String = "dgSearch")

' Inject Jscript to attack click event to grid
page.RegisterStartupScript(Guid.NewGuid.ToString, "<script
language=javascript>" + gridName + ".attachEvent('onclick',

End Sub

"HighlightTableRow" is defined in a .js file which is included in the
..aspx, as is the function "DoClick".

We have about a dozen of these builder forms and they work well. They
display the table rows, the user clicks on the row to edit it, and the
Datagrid flips into edit mode.

However, on the form I am working on, the form fails to load with the
following error:

Microsoft JScript runtime error: 'dgSearch' is undefined

on the line which comes from the second function:

<script language=javascript>dgSearch.attachEvent('onclick' , DoClick);

(dgSearch is the company-mandated name for the Datagrid)

What appears to be happening is that in the HTML prior to the line
causing the error, there is no "dgSearch" control loaded. Where I
would expect it to be is completely blank!

<TABLE id="Table10" cellSpacing="0" cellPadding="0"
<TD><IMG src="../../images/mnus32.gif" border="0">
<TD width="100%">
<table cellspacing="2" cellpadding="2" id="wmSubMenu"
</TR> <!-- Grid Results -->

Does anyone have a clue where it might have gone? I think the problem
may be in the order the objects are rendered, but I can't find
anything different about this form than any other which works fine.

Many thanks if you've made it this far!

The reading group's reading group:
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
seems w32.Esbot.B is starting to cause mayhem thing2 NZ Computing 2 08-20-2005 02:55 AM
Creating ClientSide code thru PreRender =?iso-8859-1?Q?Ti=EBsto?= ASP .Net 3 11-13-2004 05:35 AM
will all these messages cause a problem . I am a new subscriber and my computer is downloading 100,000 messages. Will this cause any kind of a problem with my ability to store other items?? Camille White Camille White Computer Support 9 11-08-2004 01:13 AM
Why does this cause an Obect required message? It seems to work... Iver Erling Årva Javascript 2 08-19-2004 10:17 AM
Re: Assigning events in PreRender Simon Storr ASP .Net 0 07-14-2003 10:47 AM