473,804 Members | 2,173 Online
Bytes | Software Development & Data Engineering Community
+ 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:UpdatePane l ID="up1" runat="server">
<ContentTemplat e>
<asp:DataGrid ID="Components " runat="server" ...>
<Columns>
<asp:TemplateCo lumn>
<FooterTemplate >
<asp:PlaceHolde r ID="ph" runat="server"> </asp:PlaceHolder >
</FooterTemplate>
</asp:TemplateCol umn>
</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(LoadContr ol("~/myUserControl.a scx"), myUC)
End Sub

Private Sub Page_Load
BuildDataGrid()
End Sub

Protected Sub Components_Item DataBound
Select Case e.Item.ItemType
Case ListItemType.Fo oter
Dim ph As PlaceHolder = CType(e.Item.Fi ndControl("ph") , PlaceHolder)
excip.Property1 = ""
excip.Property2 = ""
ph.Controls.Add (excip)
End Sub

Protected Sub Components_Item Command
'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.ClientScri pt.IsClientScri ptIncludeRegist ered(Me.GetType ,
"jsRef")) Then
Page.ClientScri pt.RegisterClie ntScriptInclude (Me.GetType, "jsRef",
ResolveClientUr l("~/myUserControl.j s"))

Dim sb as New StringBuilder
sb.Append("dyna mic javascript")
ScriptManager.R egisterStartupS cript(Literal1, Me.GetType(), "dynamicJS" ,
sb.ToString, False)
End If
End Sub
myUserControl.j s:
function myStuff(txtbox) {
this.textbox = txtbox;

this.init();
}

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

this.textbox.on blur = function (event) {
doStuff(oThis.t extbox);
};
};
Produced validation code:
function anonymous() {
ValidatedContro lOnBlur(event);
doStuff(oThis.t extbox);
}
Jun 27 '08 #1
0 1343

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

Similar topics

2
11206
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 this case), and the Button2 linkbutton perform redirect to another page. When I click on Button2 it returns a new page content as the result of the asynchronous request. <asp:UpdatePanel ID="up" runat="server"> <ContentTemplate>
2
2815
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 it. In the updatepanel is an ASP.NET image button that does a postback. So, it looks like this: aspx.updatepanel.Add(LoadControl(ascx control)) --ascx.updatepanel --imagebutton
1
5218
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 (visible="false" which I set in the RowDataBound Event). I have put the DateTime TextBox inside an updatepanel with an asynchronous trigger on the checkbox. It is hiding and displaying perfectly with the updatepanel whenever the checkbox is selected....
4
9089
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 down list and then another image. I want to align the images so that they are in the middle of the row so to speak, ie, not at the top. As the updatePanel simply renders a DIV tag I figured that I would be able to do something like:
2
15077
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 been able to find the cause of the problem, and will describe it here first textually and then through a code example. The purpose of what I am trying to do is to create a postback-free web application through the use of ASP.net AJAX UpdatePanels...
3
8212
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 ButtonClick in UserControl doesn't fire. <asp:ScriptManager ID="ScriptManager" EnableViewState="true" runat="server" EnablePageMethods="True" >
1
8204
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 behaviour: it's a webform with some VB code-behind, you shoud create a new AJAX-enabled application and past the following code. (DEFAULT.ASPX) <%@ Page Language="VB" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" %> <html...
0
2963
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 UpdatePanel is located outside the GridView....
13
3522
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 allowing the user to make a selection from the popup window. I have enabled AJAX extensions and have a working sample outside of a gridview. However, when I click in the textbox of a gridview row, all I see is a really small square instead of the...
0
9711
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
10595
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10088
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...
1
7633
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6862
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5529
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
5668
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3001
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.