Connecting Tech Pros Worldwide Help | Site Map

Button Click event not getting called

  #1  
Old November 20th, 2008, 10:55 PM
SAL
Guest
 
Posts: n/a
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>


  #2  
Old November 20th, 2008, 11:45 PM
=?Utf-8?B?YnJ1Y2UgYmFya2Vy?=
Guest
 
Posts: n/a

re: Button Click event not getting called


an update panel will not postback if validation has an error.

-- bruce (sqlwork.com)


"SAL" wrote:
Quote:
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>
>
>
>
  #3  
Old November 21st, 2008, 12:05 AM
SAL
Guest
 
Posts: n/a

re: Button Click event not getting called


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" <brucebarker@discussions.microsoft.comwrote in message
news:242BB717-D820-436D-8A87-80E6D3C193C8@microsoft.com...
Quote:
an update panel will not postback if validation has an error.
>
-- bruce (sqlwork.com)
>
>
"SAL" wrote:
>
Quote:
>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>
>>
>>
>>

  #4  
Old November 21st, 2008, 03:15 AM
Allen Chen [MSFT]
Guest
 
Posts: n/a

re: Button Click event not getting called


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:
msdnmg@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.

  #5  
Old November 21st, 2008, 04:35 PM
SAL
Guest
 
Posts: n/a

re: Button Click event not getting called


Sweet.
That did the trick Allen thanks.
Appreciate the help once again....


S

"Allen Chen [MSFT]" <v-alchen@online.microsoft.comwrote in message
news:xrOYcX4SJHA.6088@TK2MSFTNGHUB02.phx.gbl...
Quote:
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:
msdnmg@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.
>

Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Click event saving duplicate records into the database =?Utf-8?B?SGV6YWw=?= answers 2 February 11th, 2008 09:45 PM
addhandler event not firing laxmibokka answers 2 June 18th, 2007 01:50 AM
Button click event not firing Winista answers 4 February 14th, 2006 09:45 PM
DataGrid control events like Sort, page, Item not getting fired... Gunjan Garg answers 1 November 19th, 2005 04:03 PM