Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am facing a problem with OnClick event of my button. Scenario is that I have an Update panel and few controls inside it. When i left a textbox empty in the update panel then the Onclick event of button next to it doesn't fire. Also its not mandatory to fill textbox before button.
There is a service call on Onclick event. Also there is Next button at the bottom of the page.

Below is the code snippet:

XML
<asp:UpdatePanel ID="updatePnlPropertyType" runat="server">
                    <ContentTemplate>

 <div id="rebuild" class="elements">

                    <label class="formLabel">
                        Rebuild Cost (£):<span class="required">*</span></label>
                    <asp:TextBox runat="server" name="ddrebuild" ID="ddrebuild" CssClass="inputRebuildCost"
                        onBlur="changeClass('rebuild', 0);" onFocus="changeClass('rebuild', 1);"
                        onChange="changeClass('rebuild', 0);"></asp:TextBox>

  <VAM:RangeValidator ID="vrebuildrange" runat="server" ControlIDToEvaluate="ddrebuild"
                       //Validation code here
                </VAM:RangeValidator>

 </div>

<div id="calc_rebuild_cost" runat="server">
                    <vam:ImageButton ID="btnRebuildCalc" runat="server"  Group="calc_rebuild_cost"   CssClass="LeftPaddedButton" AlternateText="Calculate Rebuild Cost" ImageUrl="~/img/Images/calc_rebuild_cost.png"  OnClick="btnRebuildCalc_Click"/>
                </div>

</ContentTemplate>
        </asp:UpdatePanel>



Please give me a sol ASAP.

Thanks


Hi all,

I have changed my desgin code to following but still button Onclick is not firing after validation message:

XML
<asp:UpdatePanel ID="updatePnlPropertyType" runat="server" UpdateMode="Conditional">
                    <ContentTemplate>

 <div id="rebuild" class="elements">
                    <a href="javascript:helpTips('rebuild', 1);" class="help" title="help">help</a>
                    <label class="formLabel">
                        Rebuild Cost (£):<span class="required">*</span></label>
                    <asp:TextBox runat="server" name="ddrebuild" ID="ddrebuild" CssClass="inputRebuildCost"
                        onBlur="changeClass('rebuild', 0);" onFocus="changeClass('rebuild', 1);"
                        onChange="changeClass('rebuild', 0);"></asp:TextBox>
                </div>

 <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
                    <ContentTemplate>
                     <div id="calc_rebuild_cost" runat="server">
                    <vam:ImageButton ID="btnRebuildCalc" runat="server" CssClass="LeftPaddedButton" AlternateText="Calculate Rebuild Cost" ImageUrl="~/img/Images/calc_rebuild_cost.png"  OnClick="btnRebuildCalc_Click"/>
                </div>
                <div id="rebuild_cost" class="rebuildMsgtxt" runat="server">
                    <asp:Literal ID="litRebuildCost" runat="server"></asp:Literal>
                </div>

                  </ContentTemplate>
        </asp:UpdatePanel>
 </ContentTemplate>
</asp:UpdatePanel>


Now i have placed button inside another nested panel but event is not firing up.
Plz help me out...
Posted
Updated 17-Jan-14 0:52am
v3

Make sure the page you are running do not have any run-time error. also check this solution which closely resembles with your problem.

http://stackoverflow.com/questions/7650592/button-inside-update-panel-is-not-triggered-in-asp-net[^]
 
Share this answer
 
XML
<asp:TextBox ID="txt" runat="server"></asp:TextBox>
 <asp:RequiredFieldValidator ID="req1" runat="server" ControlToValidate="txt" ErrorMessage="Please Enter Value"></asp:RequiredFieldValidator>
 <asp:Button ID="btn" runat="server" onclick="btn_Click" CausesValidation="false"/>
 
Share this answer
 
Plz give your validation code

XML
<VAM:RangeValidator ID="vrebuildrange" runat="server" ControlIDToEvaluate="ddrebuild"
                       //Validation code here
                </VAM:RangeValidator>

or u might have did any wrong in rangevalidation. U might set
C#
minimumValue
property of
C#
rangevalidator 
control

do check and let me know..
 
Share this answer
 
Comments
chandrayog.2 13-Jan-14 4:20am    
hi Sukanta,

problem is not with validation, its run fien. thing is that after validation fires the Onclick code is not execute of button which is also in update panel. i think its make any sense?
Suk@nta 13-Jan-14 4:27am    
did u checked weather the double click of button in design view goes to above onclick function.
It some time changed . plz try it. and let me know
Suk@nta 13-Jan-14 4:32am    
ok ..U have forgeten to add AsyncPostBackTrigger event.. try it and let me know

<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnRebuildCalc" EventName="Click" />
</Triggers>
Suk@nta 13-Jan-14 4:35am    
ok ..U have forgeten to add AsyncPostBackTrigger event..add it after content template but before end of updatepanel and let me know

<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnRebuildCalc" EventName="Click" />
</Triggers>
chandrayog.2 17-Jan-14 1:25am    
Hi,

I have added this but no success. Strange thing is that it runs fine on very first time. but after that onclick event not working if there is any validation messge. Alos i have treid removing update panel then it works fine. dont know eats happening. plz help me out
<asp:textbox id="txt" runat="server" xmlns:asp="#unknown">
<asp:requiredfieldvalidator id="req1" runat="server" controltovalidate="txt" errormessage="Please Enter Value" xmlns:asp="#unknown">
<asp:button id="btn" runat="server" onclick="btn_Click" causesvalidation="false" xmlns:asp="#unknown">
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900