473,407 Members | 2,629 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,407 software developers and data experts.

Button Click event not getting called

SAL
Hello,
I'm working, basically my first, AJAX page and am having a few problems.
One is that the Click event for a button I have in UpdatePanel1 is not
getting called. I've tried with the button both inside and outside of the
updatepanel and the event doesn't get called either way. What might I be
missing here?

Incidently, something else, kind of weird, is happening when the button is
clicked, a required field validator control in a detailsview that I have on
the page displays it's text, which in this case is just an astrix.
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always">
<ContentTemplate>
<asp:GridView ID="gvStormDetail"
runat="server"
AutoGenerateColumns="False"
DataSourceID="dsStormDetail"
EnableViewState="False"
SkinID="gridviewSkin"
Width="672px"
DataKeyNames="StormValueID">
<Columns>
<asp:CommandField ShowDeleteButton="True" />
<asp:TemplateField>
<ItemTemplate>
<asp:HyperLink ID="hlMap" runat="server"
Target="_map">Map</asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="StormValueID"
HeaderText="StormValueID" InsertVisible="False"
ReadOnly="True" SortExpression="StormValueID"
Visible="False" />
<asp:BoundField DataField="StormAssetType"
HeaderText="Asset Category" SortExpression="StormAssetType" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="StormAssetTypeID"
HeaderText="StormAssetTypeID" SortExpression="StormAssetTypeID"
Visible="False" />
<asp:BoundField DataField="StormAssetName"
HeaderText="Storm Asset Name" SortExpression="StormAssetName" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="StmFacilityClkID"
HeaderText="StmFacilityClkID" SortExpression="StmFacilityClkID" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:TemplateField HeaderText="Description"
SortExpression="Description">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server"
Text='<%# Bind("Description") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblDescription" runat="server"
EnableViewState="False" Height="24px"
Text='<%# Bind("Description") %>'
Width="232px"></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Estimated Value"
SortExpression="EstValue">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server"
Text='<%# Bind("EstValue") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblEstValue" runat="server"
Text='<%# Bind("EstValue", "{0:C0}") %>'></asp:Label>
<asp:TextBox ID="txtEstValue" runat="server"
EnableViewState="False" Text='<%# Bind("EstValue", "{0:C0}") %>'
Visible="False" Width="96px"></asp:TextBox>
</ItemTemplate>
<ItemStyle HorizontalAlign="Right" />
</asp:TemplateField>
<asp:BoundField DataField="CntyAssetID"
HeaderText="CntyAssetID" SortExpression="CntyAssetID"
Visible="False" />
<asp:TemplateField></asp:TemplateField>
<asp:BoundField DataField="ModUser" HeaderText="ModUser"
SortExpression="ModUser">
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="ModDate"
DataFormatString="{0:MM/dd/yyyy}" HeaderText="ModDate"
HtmlEncode="False" SortExpression="ModDate">
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
</Columns>
</asp:GridView>
<br />
<asp:ObjectDataSource ID="dsStormDetail" runat="server"
SelectMethod="GetStormAssetsByCntyAssetdId"
TypeName="StormAssetsMainBLL"
EnableViewState="False"
DeleteMethod="Delete">
<SelectParameters>
<asp:SessionParameter Name="id"
SessionField="cntyAssetId" Type="Int32" />
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name="stormValueId" Type="Int32" />
</DeleteParameters>
</asp:ObjectDataSource>
<br />
<asp:Button ID="btnUpdate" runat="server" EnableViewState="False"
Text="Update All" OnClick="btnUpdate_Click"/>
<br />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="dvStormInsert"
EventName="ItemInserting" />
</Triggers>
</asp:UpdatePanel>
Nov 20 '08 #1
4 3704
an update panel will not postback if validation has an error.

-- bruce (sqlwork.com)
"SAL" wrote:
Hello,
I'm working, basically my first, AJAX page and am having a few problems.
One is that the Click event for a button I have in UpdatePanel1 is not
getting called. I've tried with the button both inside and outside of the
updatepanel and the event doesn't get called either way. What might I be
missing here?

Incidently, something else, kind of weird, is happening when the button is
clicked, a required field validator control in a detailsview that I have on
the page displays it's text, which in this case is just an astrix.
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always">
<ContentTemplate>
<asp:GridView ID="gvStormDetail"
runat="server"
AutoGenerateColumns="False"
DataSourceID="dsStormDetail"
EnableViewState="False"
SkinID="gridviewSkin"
Width="672px"
DataKeyNames="StormValueID">
<Columns>
<asp:CommandField ShowDeleteButton="True" />
<asp:TemplateField>
<ItemTemplate>
<asp:HyperLink ID="hlMap" runat="server"
Target="_map">Map</asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="StormValueID"
HeaderText="StormValueID" InsertVisible="False"
ReadOnly="True" SortExpression="StormValueID"
Visible="False" />
<asp:BoundField DataField="StormAssetType"
HeaderText="Asset Category" SortExpression="StormAssetType" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="StormAssetTypeID"
HeaderText="StormAssetTypeID" SortExpression="StormAssetTypeID"
Visible="False" />
<asp:BoundField DataField="StormAssetName"
HeaderText="Storm Asset Name" SortExpression="StormAssetName" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="StmFacilityClkID"
HeaderText="StmFacilityClkID" SortExpression="StmFacilityClkID" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:TemplateField HeaderText="Description"
SortExpression="Description">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server"
Text='<%# Bind("Description") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblDescription" runat="server"
EnableViewState="False" Height="24px"
Text='<%# Bind("Description") %>'
Width="232px"></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Estimated Value"
SortExpression="EstValue">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server"
Text='<%# Bind("EstValue") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblEstValue" runat="server"
Text='<%# Bind("EstValue", "{0:C0}") %>'></asp:Label>
<asp:TextBox ID="txtEstValue" runat="server"
EnableViewState="False" Text='<%# Bind("EstValue", "{0:C0}") %>'
Visible="False" Width="96px"></asp:TextBox>
</ItemTemplate>
<ItemStyle HorizontalAlign="Right" />
</asp:TemplateField>
<asp:BoundField DataField="CntyAssetID"
HeaderText="CntyAssetID" SortExpression="CntyAssetID"
Visible="False" />
<asp:TemplateField></asp:TemplateField>
<asp:BoundField DataField="ModUser" HeaderText="ModUser"
SortExpression="ModUser">
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="ModDate"
DataFormatString="{0:MM/dd/yyyy}" HeaderText="ModDate"
HtmlEncode="False" SortExpression="ModDate">
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
</Columns>
</asp:GridView>
<br />
<asp:ObjectDataSource ID="dsStormDetail" runat="server"
SelectMethod="GetStormAssetsByCntyAssetdId"
TypeName="StormAssetsMainBLL"
EnableViewState="False"
DeleteMethod="Delete">
<SelectParameters>
<asp:SessionParameter Name="id"
SessionField="cntyAssetId" Type="Int32" />
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name="stormValueId" Type="Int32" />
</DeleteParameters>
</asp:ObjectDataSource>
<br />
<asp:Button ID="btnUpdate" runat="server" EnableViewState="False"
Text="Update All" OnClick="btnUpdate_Click"/>
<br />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="dvStormInsert"
EventName="ItemInserting" />
</Triggers>
</asp:UpdatePanel>
Nov 20 '08 #2
SAL
That detailsView is in another updatepanel though Bruce. I have two
updatepanels on the page. Updatepanel1 has a Gridview and a button called
btnUpdate.
Updatepanel2 has a detailsview in it. That's where the requiredfield
validator is. Why in the world would it ...
Oh, is it because I have the UpdateMode in Updatepanel1 set to always? If
it's not set to always, it doesn't update when a new record is added via the
detailsview in Updatepanel2...
That can't be it because I've put the btnUpdate both inside and outside of
UpdatePanel1...

Is this making any sense???

S

"bruce barker" <br*********@discussions.microsoft.comwrote in message
news:24**********************************@microsof t.com...
an update panel will not postback if validation has an error.

-- bruce (sqlwork.com)
"SAL" wrote:
>Hello,
I'm working, basically my first, AJAX page and am having a few problems.
One is that the Click event for a button I have in UpdatePanel1 is not
getting called. I've tried with the button both inside and outside of the
updatepanel and the event doesn't get called either way. What might I be
missing here?

Incidently, something else, kind of weird, is happening when the button
is
clicked, a required field validator control in a detailsview that I have
on
the page displays it's text, which in this case is just an astrix.
<asp:UpdatePanel ID="UpdatePanel1" runat="server"
UpdateMode="Always">
<ContentTemplate>
<asp:GridView ID="gvStormDetail"
runat="server"
AutoGenerateColumns="False"
DataSourceID="dsStormDetail"
EnableViewState="False"
SkinID="gridviewSkin"
Width="672px"
DataKeyNames="StormValueID">
<Columns>
<asp:CommandField ShowDeleteButton="True" />
<asp:TemplateField>
<ItemTemplate>
<asp:HyperLink ID="hlMap" runat="server"
Target="_map">Map</asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="StormValueID"
HeaderText="StormValueID" InsertVisible="False"
ReadOnly="True" SortExpression="StormValueID"
Visible="False" />
<asp:BoundField DataField="StormAssetType"
HeaderText="Asset Category" SortExpression="StormAssetType" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="StormAssetTypeID"
HeaderText="StormAssetTypeID" SortExpression="StormAssetTypeID"
Visible="False" />
<asp:BoundField DataField="StormAssetName"
HeaderText="Storm Asset Name" SortExpression="StormAssetName" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="StmFacilityClkID"
HeaderText="StmFacilityClkID" SortExpression="StmFacilityClkID" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:TemplateField HeaderText="Description"
SortExpression="Description">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server"
Text='<%# Bind("Description") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblDescription" runat="server"
EnableViewState="False" Height="24px"
Text='<%# Bind("Description") %>'
Width="232px"></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Estimated Value"
SortExpression="EstValue">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server"
Text='<%# Bind("EstValue") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblEstValue" runat="server"
Text='<%# Bind("EstValue", "{0:C0}") %>'></asp:Label>
<asp:TextBox ID="txtEstValue" runat="server"
EnableViewState="False" Text='<%# Bind("EstValue", "{0:C0}") %>'
Visible="False"
Width="96px"></asp:TextBox>
</ItemTemplate>
<ItemStyle HorizontalAlign="Right" />
</asp:TemplateField>
<asp:BoundField DataField="CntyAssetID"
HeaderText="CntyAssetID" SortExpression="CntyAssetID"
Visible="False" />
<asp:TemplateField></asp:TemplateField>
<asp:BoundField DataField="ModUser"
HeaderText="ModUser"
SortExpression="ModUser">
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="ModDate"
DataFormatString="{0:MM/dd/yyyy}" HeaderText="ModDate"
HtmlEncode="False" SortExpression="ModDate">
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
</Columns>
</asp:GridView>
<br />
<asp:ObjectDataSource ID="dsStormDetail" runat="server"
SelectMethod="GetStormAssetsByCntyAssetdId"
TypeName="StormAssetsMainBLL"
EnableViewState="False"
DeleteMethod="Delete">
<SelectParameters>
<asp:SessionParameter Name="id"
SessionField="cntyAssetId" Type="Int32" />
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name="stormValueId" Type="Int32" />
</DeleteParameters>
</asp:ObjectDataSource>
<br />
<asp:Button ID="btnUpdate" runat="server" EnableViewState="False"
Text="Update All" OnClick="btnUpdate_Click"/>
<br />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="dvStormInsert"
EventName="ItemInserting" />
</Triggers>
</asp:UpdatePanel>

Nov 21 '08 #3
Hi,

The validation will still stop the postback even the Validation control and
the Button control are put in different UpdatePanels.

To see if it's caused by the client side validation you can try to set
CausesValidation="false" to test:

<asp:Button ID="btnUpdate" runat="server" EnableViewState="False"
Text="Update All" OnClick="btnUpdate_Click"
CausesValidation="false"/>

Can the Click event handler get called in this way?

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****@microsoft.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 21 '08 #4
SAL
Sweet.
That did the trick Allen thanks.
Appreciate the help once again....
S

"Allen Chen [MSFT]" <v-******@online.microsoft.comwrote in message
news:xr**************@TK2MSFTNGHUB02.phx.gbl...
Hi,

The validation will still stop the postback even the Validation control
and
the Button control are put in different UpdatePanels.

To see if it's caused by the client side validation you can try to set
CausesValidation="false" to test:

<asp:Button ID="btnUpdate" runat="server" EnableViewState="False"
Text="Update All" OnClick="btnUpdate_Click"
CausesValidation="false"/>

Can the Click event handler get called in this way?

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****@microsoft.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 21 '08 #5

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

Similar topics

3
by: Jason Kyle Baginski | last post by:
Here's a little test app to demonstrate a problem I'm having. It creates four buttons, each one with the different FlatStyle types available. Three of them behave exactly the same way(and the...
1
by: Divya | last post by:
Hello This is my 1st project where I have to create a Webcontrol. I have created a simple custom control with a button and 2 labels added to a panel. My problem is that the event handler that I...
2
by: Oney | last post by:
I want to open a popup window when user click the web server button control When user click the button, only OnClik="OpenWindow(12)" is sent but no event happend no popup opened.After...
1
by: Steve | last post by:
Hello, In my first (of 2) aspx page I have 2 listboxes. I populate the first listbox in the PageLoad event If Not IsPostBack Then .... When I select an item from the first listbox, lst1,...
3
by: Imran Aziz | last post by:
Hello All, I have a search text and button that post data and my button handler filters the repeater control. However when the button is clicked the first time. The page_load event is being called...
3
by: Chris Dunaway | last post by:
I have derived a class from the System.Windows.Forms.Button class in order to draw the button differently. Among other things, I paint the background of the button in the OnPaing override. ...
4
by: Bob | last post by:
Hi, I'm working with VWD and i defined programmatically a button (in code-behind) with an ID. So I expect to see beside "Page Events" and "Form1" my button "b1" in order to use the Click event....
9
by: Jonathan Wood | last post by:
Does anyone know of any reason a button on a master page would have no effect? I have a complex HTML page that I'm converting to ASP.NET, and acknowledge I could have something odd that is...
4
by: =?Utf-8?B?c21heQ==?= | last post by:
I'm trying to raise the click event of a button from my Page_Load event so that after the Page_Load completes the myBtn_Click event is fired, just as if a user had clicked the button. I can't just...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
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
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 project—planning, coding, testing,...
0
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...

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.