473,655 Members | 3,112 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

AJAX question (I think)

SAL
Hello,
I'm using vs2005 and ajax exentions 1.0.61025.0.
I have a page with a Gridview control that's inside of an update panel. I
also have a DetailsView on this page inside of another update panel. The
Detailsview handles the inserting of records into the Gridview.

The page is behaving as expected except the ItemInserting event (and there
the inserting) is being called twice. I have logic in place that is handling
this but it would be nice if the inserting events were not being called
twice and I don't see why this is happening. I'm including the html and the
code behind in case it could help. I'm sure this is simple but I just am not
getting it.

Thanks in advance
S
HTML:
<asp:ScriptMana ger ID="ScriptManag er1" runat="server">
</asp:ScriptManag er>
<asp:UpdatePane l ID="UpdatePanel 1" runat="server">
<ContentTemplat e>
<asp:GridView ID="gvStormDeta il" runat="server"
AutoGenerateCol umns="False" DataSourceID="d sStormDetail"
EnableViewState ="False" SkinID="gridvie wSkin" Width="568px">
<Columns>
<asp:BoundFie ld DataField="Stor mValueID"
HeaderText="Sto rmValueID" InsertVisible=" False"
ReadOnly="True" SortExpression= "StormValue ID"
Visible="False" />
<asp:BoundFie ld DataField="Stor mAssetType"
HeaderText="Ass et Category" SortExpression= "StormAssetType " >
<ItemStyle HorizontalAlign ="Center" />
</asp:BoundField>
<asp:BoundFie ld DataField="Stor mAssetTypeID"
HeaderText="Sto rmAssetTypeID" SortExpression= "StormAssetType ID"
Visible="False" />
<asp:BoundFie ld DataField="Stor mAssetName"
HeaderText="Sto rm Asset Name" SortExpression= "StormAssetName " >
<ItemStyle HorizontalAlign ="Center" />
</asp:BoundField>
<asp:BoundFie ld DataField="Uniq ueID"
HeaderText="Uni queID" SortExpression= "UniqueID" >
<ItemStyle HorizontalAlign ="Center" />
</asp:BoundField>
<asp:BoundFie ld DataField="Desc ription"
HeaderText="Des cription" SortExpression= "Descriptio n" >
<ItemStyle HorizontalAlign ="Center" />
</asp:BoundField>
<asp:BoundFie ld DataField="EstV alue"
HeaderText="Est imated Value" SortExpression= "EstValue"
DataFormatStrin g="{0:C0}" HtmlEncode="Fal se" >
<ItemStyle HorizontalAlign ="Right" />
</asp:BoundField>
<asp:BoundFie ld DataField="Cnty AssetID"
HeaderText="Cnt yAssetID" SortExpression= "CntyAssetI D"
Visible="False" />
</Columns>
</asp:GridView>
<br />
<asp:ObjectData Source ID="dsStormDeta il" runat="server"
OldValuesParame terFormatString ="original_{ 0}"
SelectMethod="G etStormAssetsBy CntyAssetdId"
TypeName="Storm AssetsMainBLL" EnableViewState ="False">
<SelectParamete rs>
<asp:SessionPar ameter Name="id"
SessionField="c ntyAssetId" Type="Int32" />
</SelectParameter s>
</asp:ObjectDataS ource>
<br />
</ContentTemplate >
<Triggers>
<asp:AsyncPostB ackTrigger ControlID="dvSt ormInsert"
EventName="Item Inserted" />
</Triggers>
</asp:UpdatePanel >
<asp:UpdatePane l ID="upInsert" runat="server" EnableViewState ="False"
UpdateMode="Con ditional" ChildrenAsTrigg ers="False">
<ContentTemplat e>
<asp:Label ID="lblAssetTyp e" runat="server"
EnableViewState ="False" Font-Size="10pt"
Text="Category" Width="88px" BackColor="#EFE FEF"
Height="18px"></asp:Label><asp: DropDownList ID="ddlAssetTyp e" runat="server"
AutoPostBack="T rue" DataSourceID="d sAssetTypes"
DataTextField=" StormAssetType"
DataValueField= "StormAssetType ID"
Width="156px"
EnableViewState ="False">
</asp:DropDownLis t><asp:ObjectDa taSource
ID="dsAssetType s" runat="server"
OldValuesParame terFormatString ="original_{ 0}"
SelectMethod="G etAssetTypesPlu sNone"
TypeName="Storm AssetTypeBLL" EnableViewState ="False"></asp:ObjectDataS ource>
<br />
<asp:DetailsVie w ID="dvStormInse rt"
runat="server"
DefaultMode="In sert"
EnableViewState ="False"
Height="50px"
Width="280px"
SkinID="details viewSkin"
AutoGenerateRow s="False"
DataKeyNames="S tormValueID"
DataSourceID="d sStormInsert"
OnItemInserted= "dvStormInsert_ ItemInserted"
OnItemInserting ="dvStormInsert _ItemInserting" >
<Fields>
<asp:BoundFie ld DataField="Stor mValueID"
HeaderText="Sto rmValueID" InsertVisible=" False"
ReadOnly="True" SortExpression= "StormValue ID" />
<asp:TemplateFi eld HeaderText="Cnt yAssetID"
SortExpression= "CntyAssetI D">
<EditItemTempla te>
<asp:TextBox ID="TextBox1" runat="server"
Text='<%# Bind("CntyAsset ID") %>'></asp:TextBox>
</EditItemTemplat e>
<InsertItemTemp late>
<asp:TextBox ID="txtCntyAsse tId" runat="server"
Enabled="False" EnableViewState ="False"
Text='<%# Bind("CntyAsset ID")
%>'></asp:TextBox>
</InsertItemTempl ate>
<ItemTemplate >
<asp:Label ID="Label1" runat="server" Text='<%#
Bind("CntyAsset ID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Sto rm Asset"
SortExpression= "StormAsset ID">
<EditItemTempla te>
<asp:TextBox ID="TextBox2" runat="server"
Text='<%# Bind("StormAsse tID") %>'></asp:TextBox>
</EditItemTemplat e>
<InsertItemTemp late>
<asp:DropDownLi st ID="ddlStormAss et"
runat="server"
DataSourceID="d sStormAsset"
DataTextField=" StormAssetName"
DataValueField= "StormAsset ID"
Width="156px">
</asp:DropDownLis t>
<asp:ObjectData Source ID="dsStormAsse t"
runat="server"
OldValuesParame terFormatString ="original_{ 0}"
SelectMethod="G etStormAssetsBy AssetTypeId"
TypeName="Storm AssetsBLL">
<SelectParamete rs>
<asp:ControlPar ameter
ControlID="ddlA ssetType" Name="id" PropertyName="S electedValue"
Type="Int32" />
</SelectParameter s>
</asp:ObjectDataS ource>
</InsertItemTempl ate>
<ItemTemplate >
<asp:Label ID="Label2" runat="server" Text='<%#
Bind("StormAsse tID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Des cription"
SortExpression= "Descriptio n">
<EditItemTempla te>
<asp:TextBox ID="TextBox4" runat="server"
Text='<%# Bind("Descripti on") %>'></asp:TextBox>
</EditItemTemplat e>
<InsertItemTemp late>
<asp:TextBox ID="txtDescript ion" runat="server"
Text='<%# Bind("Descripti on") %>'></asp:TextBox>
</InsertItemTempl ate>
<ItemTemplate >
<asp:Label ID="Label4" runat="server" Text='<%#
Bind("Descripti on") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Uni queID"
SortExpression= "UniqueID">
<EditItemTempla te>
<asp:TextBox ID="TextBox5" runat="server"
Text='<%# Bind("UniqueID" ) %>'></asp:TextBox>
</EditItemTemplat e>
<InsertItemTemp late>
<asp:TextBox ID="txtUniqueId " runat="server"
Text='<%# Bind("UniqueID" ) %>'></asp:TextBox>
<asp:RequiredFi eldValidator ID="rfvUniqueId "
runat="server" EnableViewState ="False"
ErrorMessage="U niqueID is a required field"
ControlToValida te="txtUniqueId ">*</asp:RequiredFie ldValidator>
</InsertItemTempl ate>
<ItemTemplate >
<asp:Label ID="Label5" runat="server" Text='<%#
Bind("UniqueID" ) %>'></asp:Label>
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld ShowHeader="Fal se">
<InsertItemTemp late>
<asp:LinkButt on ID="lbInsert" runat="server"
CausesValidatio n="True" CommandName="In sert"
Text="Insert"></asp:LinkButton>
<asp:LinkButt on ID="lbCancel" runat="server"
CausesValidatio n="False" CommandName="Ca ncel"
OnClick="lbCanc el_Click"
Text="Cancel"></asp:LinkButton>
</InsertItemTempl ate>
<ItemTemplate >
<asp:LinkButt on ID="LinkButton1 " runat="server"
CausesValidatio n="False" CommandName="Ne w"
Text="New"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateFie ld>
</Fields>
</asp:DetailsView >
<asp:ObjectData Source ID="dsStormInse rt" runat="server"
EnableViewState ="False" InsertMethod="S tormValueInsert "
OldValuesParame terFormatString ="original_{ 0}" SelectMethod="G etStormValues"
TypeName="Storm ValueBLL">
<InsertParamete rs>
<asp:Paramete r Name="cntyAsset Id" Type="Int32" />
<asp:Paramete r Name="stormAsse tId" Type="Int32" />
<asp:Paramete r Name="descripti on" Type="String" />
<asp:Paramete r Name="uniqueId" Type="Int32" />
</InsertParameter s>
</asp:ObjectDataS ource>
</ContentTemplate >
<Triggers>
<asp:AsyncPostB ackTrigger ControlID="ddlA ssetType"
EventName="Sele ctedIndexChange d" />
</Triggers>
</asp:UpdatePanel >
Code Behind:
#Region "Constants"
Protected Const ASSETTYPEID As String = "assetTypeI d"
Protected Const CNTYASSETID_ROW As Integer = 0
'Protected Const ASSETTYPE_ROW As Integer = 1
Protected Const STORMASSET_ROW As Integer = 1
Protected Const DESCRIPTION_ROW As Integer = 2
Protected Const UNIQUEID_ROW As Integer = 3
Protected Const ASSETTYPE_DD As String = "ddlAssetTy pe"
Protected Const STORMASSET_DD As String = "ddlStormAs set"
Protected Const CNTYASSETID_TXT As String = "txtCntyAssetId "
Protected Const DESCRIPTION_TXT As String = "txtDescription "
Protected Const UNIQUE_TXT As String = "txtUniqueI d"
#End Region

Protected Sub dvStormInsert_I temInserting(By Val sender As Object, ByVal e
As System.Web.UI.W ebControls.Deta ilsViewInsertEv entArgs) Handles
dvStormInsert.I temInserting
e.Cancel = True
Dim ddl As DropDownList =
dvStormInsert.R ows(STORMASSET_ ROW).FindContro l(STORMASSET_DD )

If Not ddl Is Nothing Then
If ddl.SelectedVal ue = "" Then Return
Dim sBLL As New StormValueBLL
Dim stormAssetId, uid As Integer
Dim desc As String
stormAssetId = ddl.SelectedVal ue
uid = e.Values(UNIQUE ID_ROW - 1)
desc = e.Values(DESCRI PTION_ROW - 1)
sBLL.StormValue Insert(e.Values (CNTYASSETID_RO W), stormAssetId,
desc, uid)
ResetDropdowns( )
Dim txt As TextBox =
dvStormInsert.R ows(DESCRIPTION _ROW).FindContr ol(DESCRIPTION_ TXT)
If Not txt Is Nothing Then txt.Text = Nothing
txt = dvStormInsert.R ows(UNIQUEID_RO W).FindControl( UNIQUE_TXT)
If Not txt Is Nothing Then txt.Text = Nothing
upInsert.DataBi nd()
End If
End Sub

Protected Sub Page_LoadComple te(ByVal sender As Object, ByVal e As
System.EventArg s) Handles Me.LoadComplete
SetCntyAssetId( )
End Sub

Protected Sub dvStormInsert_I temInserted(ByV al sender As Object, ByVal e
As System.Web.UI.W ebControls.Deta ilsViewInserted EventArgs) Handles
dvStormInsert.I temInserted
SetCntyAssetId( )
ResetDropdowns( )
End Sub

Protected Sub SetCntyAssetId( )
Dim txt As TextBox =
dvStormInsert.R ows(CNTYASSETID _ROW).FindContr ol(CNTYASSETID_ TXT)
If Not txt Is Nothing Then
Dim id As Integer = Session("cntyAs setId")
If id 0 Then
txt.Text = id
End If
End If
End Sub

Protected Sub ResetDropdowns( )
ddlAssetType.Se lectedValue = -1
End Sub

Protected Sub lbCancel_Click( ByVal sender As Object, ByVal e As
System.EventArg s)
Me.ddlAssetType .SelectedValue = -1
Me.upInsert.Dat aBind()
'Dim ddl As DropDownList =
dvStormInsert.R ows(STORMASSET_ ROW).FindContro l(STORMASSET_DD )
'If Not ddl Is Nothing Then
' ddl.Items.Clear ()
'End If
End Sub
Nov 19 '08 #1
3 1475
Hi,

Since you're using VB.NET, both specifying:

OnItemInserting ="dvStormInsert _ItemInserting"

in aspx and specifying:

Handles dvStormInsert.I temInserting

in aspx.vb will attach the event handler to the ItemInserting event.
Therefore, the event handler will be called twice.

To solve this problem you can remove either of above ones.

Please let me know if it works.

Regards,
Allen Chen
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subs.../aa948874.aspx
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '08 #2
SAL
Ahh, yes. that did work. I don't know how that happened as I don't recall
adding it in both places.

I have another issue with this web page involving AJAX, I believe.

I have a button on this page. The Click even does not fire. However, when
the button is clicked, the text for a required field validator in the
details view appears.????

Should I repost for this question?

S

"Allen Chen [MSFT]" <v-******@online.m icrosoft.comwro te in message
news:EA******** ******@TK2MSFTN GHUB02.phx.gbl. ..
Hi,

Since you're using VB.NET, both specifying:

OnItemInserting ="dvStormInsert _ItemInserting"

in aspx and specifying:

Handles dvStormInsert.I temInserting

in aspx.vb will attach the event handler to the ItemInserting event.
Therefore, the event handler will be called twice.

To solve this problem you can remove either of above ones.

Please let me know if it works.

Regards,
Allen Chen
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support
Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subs.../aa948874.aspx
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no
rights.

Nov 20 '08 #3
Hi,

Glad to know you've solved this issue.

As to the new one, since it's a different issue I think it's better to
start a new post for it. Please post some code that can reproduce this
problem and I'll follow up.

Regards,
Allen Chen
Microsoft Online Community Support

Nov 21 '08 #4

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

Similar topics

11
2333
by: Yarco | last post by:
I want to use "Ajax" to create my web for hobby. But i don't know whether "Ajax" is mature... And what about with php? Someone have experience on it? ....
4
4308
by: bobzimuta | last post by:
I'm creating a simple AJAX library. It's an object that will return an array containing the response text or xml. I'm trying to find a way to assign the response as a property of the object, but from within an inline function. Within the AJAX object: this.xmlhttp = new XMLHttpRequest(); this.response = ''; //to contain the response text OR xml var that = this; //since we cannot reference this within the
8
1769
by: needin4mation | last post by:
I understand this is a asp.net group, but thought I would post this here for comments. I admit I have used this post in another group, but it has less traffic. Here's to hoping I'm just blind to the obvious: I have been reading a lot about AJAX. I want to use it and will. But I keep reading about how it doesn't make a roundtrip to the server, no postback, etc. But isn't the truth that *something* makes a trip to the server? It may...
8
2511
by: darrel | last post by:
I'm going to be diving into ASP.net 2.0 on a small project. I'd also like to use it as an excuse to start playing with some AJAX techniques. So, that leads to the obvious question: AJAX.net vs. Atlas? Anyone have any opinions on that? It looks like Atlas is still considered 'beta' so perhaps that's one strike against it.
7
1499
by: Thirsty Traveler | last post by:
Peter Bromberg has an interesting article eggheadcafe discussing AJAX libraries. He prefers ANTHEM.NET over AJAX.NET because it doesn't break the stateful page model. Our developers are currently using AJAX.NET after extensive research because ATLAS is currently not ready for prime-time and much more verbose than AJAX.NET. I was looking at some "Hello World" status on various libraies and ATLAS does, indeed, result in much more traffic....
31
3109
by: Tony | last post by:
I just noticed that prototype.js is one of the files in the Ajax.NET distribution - I'm pretty concerned about this. Does anyone know if this is the same "prototype.js" that is not well-liked around here? If so, do you know if Ajax.NET can be used without prototype.js? -- "The most convoluted explanation that fits all of the made-up facts is the most likely to be believed by conspiracy theorists. Fitting the
9
2072
by: Trapulo | last post by:
Hello, with ASP.NET 2.0 Ajax every unexpected error is managed client-side with a popup that reports the error to the user. In ASP.NET 3.5 this behavor has been changed: how can I have a similar behavor? I'd like that every exception raised from ASP.NET runtime during an asyncpostback is managed in client side with a popup that reports the error message. thanks
4
5355
by: Peter | last post by:
ASP.NET I have an application which use ASP.NET Autocomplete extender which works great. But I have a question how to update all the fields on the screen using Ajax. Users starts typing in a text field which causes the Autocomplete extender to display 10 like items, after the users selects an item (which is a key in the database) I want the application to go to the database retrieve a record and populate the fields.
1
2045
by: Mark B | last post by:
This is my first try at using AJAX. I want the calendars to be enabled if the user checks CheckBox1. It works OK for a normal all page refresh but once I introduced the AJAX code it stopped working. Any ideas? <%@ Page Language="VB" AutoEventWireup="false" CodeFile="default-ajax.aspx.vb" Inherits="pages_verify_groups_Default" Debug="true" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
7
4597
by: =?Utf-8?B?QmlsbHkgWmhhbmc=?= | last post by:
我们现在遇到一个问题,通过wcf创建的webservice,选择windows service作为宿主,采用java作为客户端调用成功,但是无法使用asp.net ajax调用。 我们参考了http://msdn.microsoft.com/zh-cn/library/bb410780.aspx的资料,并且下载了相应的sample code,但是发现这些sample基本上都需要在iis上部署一个svc文件,但是根据当前业务需求,我们无法部署iis服务器。...
0
8816
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
8710
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8497
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
7310
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6162
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
4150
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
4299
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1928
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1598
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.