Click here to Skip to main content
11,648,785 members (82,491 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#3.0 ASP.NET
Hi iam using an updatepanel here is my aspx code

<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>

my c# code:

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 5-Jun-13 22:05pm
Comments
Zafar Sultan at 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.
Khan Ji at 6-Jun-13 7:15am
   
@ Zafar Sultan... I think its a AsyncPostBackTrigger as mentioned over there in question...:)
Zafar Sultan at 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 :)
Khan Ji at 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

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Replace
<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: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
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.
  Permalink  
v3
Comments
ashok_89 at 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 at 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)

  Print Answers RSS
0 F-ES Sitecore 409
1 CPallini 370
2 OriginalGriff 334
3 Kornfeld Eliyahu Peter 324
4 Sergey Alexandrovich Kryukov 254
0 OriginalGriff 1,512
1 Sergey Alexandrovich Kryukov 1,022
2 jyo.net 994
3 DamithSL 986
4 CPallini 945


Advertise | Privacy | Mobile
Web04 | 2.8.150804.4 | Last Updated 6 Jun 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100