Click here to Skip to main content
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 23: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 OriginalGriff 304
1 Sergey Alexandrovich Kryukov 255
2 Shweta N Mishra 216
3 Maciej Los 210
4 PIEBALDconsult 174
0 OriginalGriff 7,660
1 Sergey Alexandrovich Kryukov 7,072
2 DamithSL 5,586
3 Manas Bhardwaj 4,946
4 Maciej Los 4,665


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 6 Jun 2013
Copyright © CodeProject, 1999-2014
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