Click here to Skip to main content
15,880,972 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
I have one ASP.Net page with Master page and some User Controls there.

That page contains one Update Panel and Ajax Tab Panel
on tab change of tab panel i will load My User Control as per tab position.
now what i want some thing like this.
in some user control i put link button for exporting data of Grid View to excel file.
i did this before with my own function but it will work only when the page is not having any update panel and if having update panel then the button which is used to export data will registered as a post back trigger in side update panel.

so i want to register my user controls export button to my Page's Update panel's post back trigger.
how to do this.?
Posted

i want to register my user controls export button to my Page's Update panel's post back trigger
All you need is to register the button as PostbackTrigger for that update panel.
XML
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
    <ContentTemplate>
       Other controls here... 
       <asp:Button id="UploadButton"
           Text="Upload file"
           OnClick="UploadButton_Click"
           runat="server">
       </asp:Button>
    </ContentTemplate>
    <Triggers>
    <asp:PostBackTrigger ControlID="UploadButton" />
    </Triggers>
</asp:UpdatePanel>

Refer: MSDN: PostBackTrigger Class[^]
 
Share this answer
 
Update Panel has AsyncPostBack triggers, within which you can embed button and point to the respective panel, this solves your problem
 
Share this answer
 
For adding Controll id to Update Panel Trigger from Child Control Codebehind page, simply use this.

use your script manager associated with that update panel like this.
pass your control like this.
VB
ToolkitScriptManager.GetCurrent(Page).RegisterPostBackControl(lnkBhaItemsExportToExcel)
 
Share this answer
 
Comments
Strange_Pirate 29-Sep-12 0:56am    
Better to use AsyncPostBack triggers !!

Wat you say Sir.
Nel Mateo 7-Aug-14 0:58am    
Thanks Tejas, among the solutions presented for this question, yours is the one that worked for my case.
Tejas Vaishnav 7-Aug-14 4:27am    
Its great to hear that, its work for you. :)

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