Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi iam using an updatepanel here is my aspx code

SQL
<asp:UpdatePanel ID="MyUpdatePanel" UpdateMode="Conditional" runat="server">
       <ContentTemplate>

<a id="btnSave" runat="server" class="button">submit
XML
</ContentTemplate>
        <Triggers>
          
            <asp:AsyncPostBackTrigger ControlID="btnSave" EventName="ServerClick" />
           
        </Triggers>
    </asp:UpdatePanel>


my c# code:

C#
public void btnSave_ServerClick(object sender,EventArgs e)
{
...
}
  
the problem here is ,when i click btnsave its not transferring the control to the btnsave(not hitting the break point of btnsave)
pls help me out.
Posted
Comments
Zafar Sultan 6-Jun-13 4:55am    
what is <a id="btnSave" runat="server" class="button">submit? If it is a button, correct its tag formation and see my solution. If it is a link, I dont think you can fire an event from server side. On clicking it, it will navigate to the specified url.
VICK 6-Jun-13 7:15am    
@ Zafar Sultan... I think its a AsyncPostBackTrigger as mentioned over there in question...:)
Zafar Sultan 6-Jun-13 7:19am    
No sir. I am talking about the tag(<a id="btnSave" runat="server" class="button">submit). It is formed like an anchor tag but the OP wants it to behave like a button :)
VICK 7-Jun-13 3:23am    
oooops .. Sorry zafar.. i actually didnt saw the non highlighted portion where defected tag is....

ya that tag is not fine.. you are right. :)

1 solution

Replace
ASP.NET
<asp:UpdatePanel ID="MyUpdatePanel" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<a id="btnSave"  runat="server" class="button">submit
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnSave" EventName="ServerClick" />
</Triggers>
</asp:UpdatePanel>

with
ASP.NET
<asp:UpdatePanel ID="MyUpdatePanel" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<asp:Button id="btnSave" runat="server" onclick="btnSave_Click" Text="Submit"/>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnSave" />
</Triggers>
</asp:UpdatePanel>


Now write in your code behind
C#
public void btnSave_Click(object sender,EventArgs e)
{

}


I have replace anchor tag with button. Because anchor tag does not fire event on server side. You have to use button. In fact you don't even have to use trigger if you have a button inside update panel.
 
Share this answer
 
v3
Comments
ashok_89 6-Jun-13 5:06am    
nope the event is not firing ,if i use <asp:asyncpostbacktrigger controlid="btnSave" eventname="btnSave_ServerClick" /> or <asp:asyncpostbacktrigger controlid="btnSave" />
iam getting error
Zafar Sultan 6-Jun-13 6:01am    
Check my updated solution.

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