473,626 Members | 3,388 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.EventArg s) Handles MyBase.PreRende r

' If in not edit mode activate row highlighting / click to edit
If Not Editing Then
BuilderForm.Act ivateRowHighlig ht(Me.Page)
BuilderForm.Act ivateClicktoEdi t(Me.Page)
End If

End Sub

This calls the following two functions:

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

' Inject Jscript to activate row highlight and selection
page.RegisterSt artupScript(Gui d.NewGuid.ToStr ing, "<script
language=javasc ript>try{Highli ghtTableRow('" + gridName +
"');}catch( e){}
</script>")

End Sub

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

' Inject Jscript to attack click event to grid
page.RegisterSt artupScript(Gui d.NewGuid.ToStr ing, "<script
language=javasc ript>" + gridName + ".attachEvent(' onclick',
DoClick);</script>")

End Sub

"HighlightTable Row" 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=javasc ript>dgSearch.a ttachEvent('onc lick', 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 1505

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

Similar topics

53
5688
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 difficult to know what is going on. One of these Order Forms you can see here... http://www.cardman.co.uk/orderform.php3
0
1318
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) grdPortals.Columns(1).HeaderText = "Title" End Sub I can see the value changed correctly when I was in debug mode, but it doesn't show on the page. It always the original value.
3
2593
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 id="SUB2" /> <SUBSECTION id="SUB3" /> </SECTION>
1
5839
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 which should be generated in uc. The Pre_Render method of uc looks like this:
3
8106
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 loads that need to occur AFTER event handlers have fired, as well as after page load and postback. Is this good, bad or common practice? example I've got a repeater on the page, and in the header of the repeater I've got
28
3024
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 reading a webpage or an HTML e-mail and getting affected through the scripting. My understanding is that the script downloads the malicious program from the web and sets it to run on start up through the start-up folder or in the registry. I...
1
3710
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 Page.Unload event. Using a performance analyzing tool (AqTime 4.9) I am not able to find out what is happening between these 2 events. Can anyone shine some light on what is normally going on between these 2 events? Thanks in advance.
0
1367
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 System.EventArgs) Handles grdPBC.PreRender If grdPBC.EditItemIndex > -1 Then Dim tbx As TextBox tbx = CType(grdPBC.Items(grdPBC.EditItemIndex).Cells(4).Controls(0), TextBox) tbx.Width = Unit.Pixel(50) ...
1
3093
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, and the key = 0 (meaning I'm inserting) I'd like to set a date field to current date. the above logic works great in another page I have where I am not checking for session information in the page load, but in th is code results in the error.
0
8268
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8202
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8366
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8510
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4093
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4202
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2628
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1812
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1512
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.