473,387 Members | 3,781 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

PreRender code seems to cause Javascript error!

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
BuilderForm.ActivateRowHighlight(Me.Page)
BuilderForm.ActivateClicktoEdit(Me.Page)
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 +
"');}catch(e){}
</script>")

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',
DoClick);</script>")

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!

<TR>
<TD>
<TABLE id="Table10" cellSpacing="0" cellPadding="0"
width="100%">
<TR>
<TD><IMG src="../../images/mnus32.gif" border="0">
</TD>
<TD width="100%">
<table cellspacing="2" cellpadding="2" id="wmSubMenu"
border="0">
<tr>
SHOULD BE HERE!!!
</tr>
</table>
</TD>
</TR>
</TABLE>
</TD>
</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!

Edward
--
The reading group's reading group:
http://www.bookgroup.org.uk
Nov 19 '05 #1
0 1491

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

53
by: Cardman | last post by:
Greetings, I am trying to solve a problem that has been inflicting my self created Order Forms for a long time, where the problem is that as I cannot reproduce this error myself, then it is...
0
by: Andy Wang | last post by:
I need change HeaderText of DataGrid in PreRender(). But it seems doesn't work. The code example like this: Protected Overrides Sub OnPreRender(ByVal e As System.EventArgs)...
3
by: Musravus | last post by:
Hi all, I have a piece of XML that looks like this, which I want to DataBind to a Repeater (the Repeater is inside a UserControl): <SECTION id="MAIN" > <SUBSECTION id="SUB1" /> <SUBSECTION...
1
by: Nikolaj | last post by:
I'm loading a user control using the method: uc = Page.LoadControl("../UC.ascx"); Afterwards I set some variables in uc. For instance uc.Count = 10; Count is the number of link buttons...
3
by: Matt Jensen | last post by:
Howdy all - and seasons greetings Just wondering, I've recently discovered the PreRender event for .NET (both for the page and for controls), which seems like a life saver for doing page data...
28
by: Noone Here | last post by:
AIUI, it was not all that long ago when the threat to personal users, was attachments that when executed compromised machines with keyloggers, trojans, etc. Now it seems that the big problem is...
1
by: Mariella Bakker | last post by:
Hi All, In an ASP.NET project I am trying to improve performance. As it is now there seems to be a huge bottleneck between the end of the Page.PreRender event and the beginning of the...
0
by: mutlyp | last post by:
I have a PreRender event to set the width of my textbox when the Edit button is pressed on my grid here is the code: Private Sub grdPBC_PreRender(ByVal sender As Object, ByVal e As...
1
by: wildman | last post by:
In the Page_load my code check to see if session variable is set, if it is, it calls some subroutines that loads some grids and binds them. In my prerender, when the grids row is in update mode,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.