473,472 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

onblur in an UpdatePanel

I'm having trouble with a datagrid in an UpdatePanel that includes a user
control in the footer and edit rows. The user control references a js file
that initializes an onblur for the textbox it contains. This is fine when
the page loads however after clicking the add button, the update panel
refreshes showing me the row I added and a new footer, but the code contained
in the onblur function has been added to the page's javascript as if it were
a validator. The problem is that at this point it can no longer reference
the appropriate objects. In other words, near the bottom of my code snippets
below, "doStuff(oThis.textbox);" is being placed into the anonymous
javascript function at the bottom, which then throws an error because oThis
is undefined. Can anyone tell me why this is happening and how to avoid it?
Any I doing something wrong that is causing this?

Parent Page HTML:
<asp:UpdatePanel ID="up1" runat="server">
<ContentTemplate>
<asp:DataGrid ID="Components" runat="server" ...>
<Columns>
<asp:TemplateColumn>
<FooterTemplate>
<asp:PlaceHolder ID="ph" runat="server"></asp:PlaceHolder>
</FooterTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
</ContentTemplate>
</asp:UpdatePanel>

Parent Page CodeBehind:
Dim excip As New myUC
Protected Sub Page_Init
initUC()
End Sub

Private Sub initUC()
excip = CType(LoadControl("~/myUserControl.ascx"), myUC)
End Sub

Private Sub Page_Load
BuildDataGrid()
End Sub

Protected Sub Components_ItemDataBound
Select Case e.Item.ItemType
Case ListItemType.Footer
Dim ph As PlaceHolder = CType(e.Item.FindControl("ph"), PlaceHolder)
excip.Property1 = ""
excip.Property2 = ""
ph.Controls.Add(excip)
End Sub

Protected Sub Components_ItemCommand
'save info

initCBO()
BuildDataGrid()
End Sub
User Control HTML:
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Literal ID="Literal1" runat="server"></asp:Literal>

User Control CodeBehind:
Private Sub Page_Load
If (Not Page.ClientScript.IsClientScriptIncludeRegistered( Me.GetType,
"jsRef")) Then
Page.ClientScript.RegisterClientScriptInclude(Me.G etType, "jsRef",
ResolveClientUrl("~/myUserControl.js"))

Dim sb as New StringBuilder
sb.Append("dynamic javascript")
ScriptManager.RegisterStartupScript(Literal1, Me.GetType(), "dynamicJS",
sb.ToString, False)
End If
End Sub
myUserControl.js:
function myStuff(txtbox) {
this.textbox = txtbox;

this.init();
}

myStuff.prototype.init = function () {
var oThis = this;

this.textbox.onblur = function (event) {
doStuff(oThis.textbox);
};
};
Produced validation code:
function anonymous() {
ValidatedControlOnBlur(event);
doStuff(oThis.textbox);
}
Jun 27 '08 #1
0 1327

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

Similar topics

2
by: marss | last post by:
Hello, I have a question concerning UpdatePanel. For example, I have two linkbuttons at the UpdatePanel. I want the Button1 linkbutton to update controls within panel (the TextBox1 control in...
2
by: brett | last post by:
I have an AJAX updatepanel in an aspx page. Inside the updatepanel is a placeholder control, which loads various ascx files. This all works fine. One of the ascx files also has an updatepanel in...
1
by: podpi | last post by:
Hello I'm having a bit of a proooblem. I have a gridview which has a checkbox as one of the templatecolumn's. When it is checked, it hides a textbox containing a DateTime templatefield...
4
by: Rob Meade | last post by:
Hi all, Ok - this might sound kinda stupid - but I cant see how to do it... I've got an update panel which contains, on one horizontal line, a drop down list, then an image, then another drop...
2
by: ChrisCicc | last post by:
Hi All, I got a real doozy here. I have read hundreds upon hundreds of forum posts and found numerous others who have replicated this problem, but have yet to find a solution. Through testing I have...
3
by: JacekDr | last post by:
Hello, I've got the following problem: I want to add and remove dynamically controls to UpdatePanel. In my user control I have a button, but when I click it I get AsyncPostback and Event for...
1
by: abellix | last post by:
An updatepanel contains a datagrid, this datagrid has columns generated by code-behind: some columns should have async postback, others should have sync postback. Here a sample to reproduce the...
0
by: Jeff | last post by:
hey asp.net 3.5 I have 2 UpdatePanels in my webpage. This webpage has a GridView, which one of its column is a templatefield which again contain a UpdatePanel and a button... The other...
13
by: SAL | last post by:
Hello, I'm trying to include a popup in the ItemTemplate of a gridview row. The ItemTemplate for the field contains a textbox and when the user clicks in the textbox I want a popup panel to show...
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...
1
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...
0
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.