AsyncPostBackTrigger is not a known element? - c#

I'm using asp.net and c#, making a page with ajax updatepanels. When I try and insert the trigger element, I get the error message AsyncPostBackTrigger is not a known element. What am I missing?
<asp:UpdatePanel ID="UdpEPL" runat="server" UpdateMode="Conditional"
Visible="False">
<ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="BtnEplShowSubmit"
EventName="BtnEplShowSubmit_Click"/>
</Triggers>
</ContentTemplate>
</asp:UpdatePanel>

Remove the Triggers section from your ContentTemplate:
<asp:UpdatePanel ...>
<Triggers>
<asp:AsyncPostBackTrigger .../>
</Triggers>
<ContentTemplate>
</ContentTemplate>
</asp:UpdatePanel>

Related

How to active AsyncPostBackTrigger in Update Panel?

I created a updatePanel, is include some dropdownlist and a few button and I use AsyncPostBackTrigger for not update all page when the click button or select dropdownlist.
My page structure that an aspx page and also use user control page. I use updatePanel on UserControlPage.
Here is My code and I wish you help me:
<asp:UpdatePanel ID="UpdMonthly" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:DropDownList ID="ddlSenetIslemleriAlinanUrun1" AutoPostBack="true" OnSelectedIndexChanged="ddlSenetIslemleriAlinanUrun1_SelectedIndexChanged" runat="server"></asp:DropDownList>
<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
<asp:Button ID="btnKaydet" style="margin:10px ;" Width="100" Height="50" runat="server" Text="Kaydet" OnClick="btnKaydet_Click"/>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlSenetIslemleriAlinanUrun1" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="btnKaydet" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
I have some knowledge on placeholder but when the click dropdown or button, page is postback and placeholder knowledge dissappear.
how to fix postback problem?
Thanks for your answers.

How to fire an event of a page in Async mode a button inside an UpdatePanel inside a UserControl?

EDITED...
I got an ASP.NET Button inside an UpdatePanel, inside a UserControl.
I want to make the IMAGE visible by CLICKing on the UserControl’s Button (btnSubmit).
Using the following js function I’m able to do it in normal postback mode, but it’s not working in Async mode.
The question is, how can I do this in an Async mode or what’s the best way to do this?
User Control (Categories):
<asp:UpdatePanel ID="upItems" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClientClick="btnSubmitPostBack();"/>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnSubmit" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
ASP.NET Page
<script>
function btnSubmitPostBack() {
__doPostBack('<%= btnDoSomething.ClientID %>', '');
}
</script>
<asp:UpdatePanel ID="up" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<uc1:Categories ID="Categories1" runat="server" CatRootName="Products" />
<asp:Button ID="btnDoSomething" CssClass="hidden" runat="server" Text=" Do Something" OnClick=" btnDoSomething_Click" />
<asp:Image ID="Image1" runat="server" Visible="false" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnDoSomething" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
protected void btnDoSomething_Click(object sender, EventArgs e)
{
Image1.Visible = true;
up.Update();
}
Thanks for your attention and help in advance!
OK here we go :( Just compiled and ran this successfully) and I think that's the right way to do it: ( the key here is to find the other user control and drill inside it for your control to update:
You user control code :
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="Categories.ascx.cs" Inherits="WebApplication1.Categories" %>
<asp:UpdatePanel ID="upItems" runat=*emphasized text*"server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click"/>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnSubmit" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
User control code behind:
protected void btnSubmit_Click(object sender, EventArgs e)
{
UpdatePanel ImageUpdatePanel = (UpdatePanel)this.Parent.FindControl("up");
Image _img = (Image)ImageUpdatePanel.FindControl("Image1");
_img.Visible = true;
//Updating UpdatePanel
ImageUpdatePanel.Update();
}
and then your page code
<asp:UpdatePanel ID="up" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<uc1:Categories ID="Categories1" runat="server" CatRootName="Products" />
<asp:Button ID="btnDoSomething" CssClass="hidden" runat="server" Text=" Do Something"/>
<asp:Image ID="Image1" runat="server" Visible="false" ImageUrl="~/Images/heroAccent.png" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnDoSomething" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
this is 100% working solution, if u need I can send u the code too :)

asp.net FileUpload doesn't work properly

I have asp:FileUpload , two asp:Button , and GridView in UpldatePanel.
<asp:FileUpload runat="server" ID="fileExcelUpload" />
<asp:Button ID="btnShow" runat="server" Width="80px" OnClick="btnShow_Clicked"
AutoPostBack="true" Text="Save"/>
<asp:Button ID="btnImport" runat="server" Width="80px" OnClick="btnImport_Clicked"
AutoPostBack="true" Text="Save"/>
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
.........GridView...........
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnShow" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="btnImport" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
Firstly , I retrieve some data from database and bind to gridView using btnShow.It works perfectly.
But when I upload Excel file with asp:FileUpload and click btnImport ,
protected void btnImport_Clicked(object sender, EventArgs e)
{
if (fileUExcelUpload.HasFile)
{
.....
}
}
the boolean value fileUExcelUpload.HasFile return False .
But when I remove <asp:AsyncPostBackTrigger ControlID="btnImport" EventName="Click" /> from UpldatePanel's triggers , it return True .
(The reason why I add btnImport's Click event to UpdatePanel's Triggers is , I want to persist Uploaded File of asp:FileUpload after postback . )
Is there any right way to do it ? Kindly help me Please :) Thanks !
Add this line in the
<Triggers> </Triggers>
<asp:PostBackTrigger ControlID="btnUpload" />
here btnUpload is the id of the fileupload control

Working with multiple update panels and timer dedicated to specific updatepanel

I have the code on master page as follows:
<asp:Timer ID="Timer1" runat="server" Interval="10000" ontick="Timer1_Tick"></asp:Timer>
<asp:UpdatePanel ID="updateNotifications" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
<ContentTemplate>
//Content
</ContentTemplate>
</asp:UpdatePanel>
This is working fine and refreshes the content with defined interval, but it also updates all the update panels on the content pages. I have to refresh only the content inside this update panel. I have tried UpdateMode="Conditional" and UpdateMode="Always" too but to no help.

Asyncpostback using standard button

Using an update panel I am attempting to perform an Async postback with a standard html button.
I have tried this:
<asp:UpdatePanel runat="server" ID="MyUpdatePanel">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnMyButton" EventName="Click" />
</Triggers>
<ContentTemplate>
<button runat="server" id="btnMyButton">ASyncPostBack</button>
</ContentTemplate>
</asp:UpdatePanel>
AND
<asp:UpdatePanel runat="server" ID="MyUpdatePanel">
<Triggers>
</Triggers>
<ContentTemplate>
<button runat="server" id="btnMyButton">ASyncPostBack</button>
</ContentTemplate>
</asp:UpdatePanel>
AsyncPostBackTrigger trigger = new AsyncPostBackTrigger();
trigger.ControlID = MyControl.ID;
trigger.EventName = "Click";
MyUpdatePanel.Triggers.Add(trigger);
Judging by my scriptmanager IsInAsyncPostBack value nether of these solutions seem to work.
I am not using a standard ASP.NET button because of issues that jQuery has with it and I am aware that I could put a hidden ASP.NET button inside the page and trigger that but am hoping for a better solution.
Event name should be EventName="onserverclick" instead EventName="Click"
Just to update others, its now works as EventName="serverclick"

Categories