button click event on update panel not firing in multiple user control - c#

I am having an update panel which user control in it
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<uc1:SelectionAjax ID="SelectionAjax1" runat="server" />
<ppmp:PinPadModal ID="ppmodal" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
and inside this user control I am calling another two user controls each user control which has its own update panel
// First User Control
<asp:UpdatePanel ID="UpP1" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnFinalConfirmation" EventName="Click" />
</Triggers>
<ContentTemplate>
<asp:Button ID="btnFinalConfirmation" runat="server" Text="Confirm" OnClick="btnFinalConfirmation_Click1" />
</ContentTemplate>
</asp:UpdatePanel>
//Second User Control
<asp:UpdatePanel ID="UpPanel1" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">
<ContentTemplate>
<asp:Button ID="btnConfirmation" runat="server" Text="Confirm" OnClick="btnConfirmation_Click1" />
</ContentTemplate>
</asp:UpdatePanel>
The issue is that button click event is only being fired on the second user control not the first one how should I solve this

Include ScriptManager in your Aspx Page.This ScriptManager control provides support for client-side AJAX features in an AJAX enabled web pages.
<asp:ScriptManager ID="ScriptManager1" runat="server"/>

Related

Multiple dynamic LinkButton avoid postback

I have many LinkButton but I want it to have singleOnClick event to all LinkButton since it will do the same thing (and I will just get the value of CommandArgument). My problem is that LinkButton keeps on doing postback which will refresh the page every time I click on a LinkButton.
I tried many solutions such us adding href="#", using OnClientClick="" property on the LinkButton control in asp.net, but what happens is it doesn't trigger the ClickEvent anymore.
Is there other way to achieve this? Or javascript is my only way in solving this problem?
<asp:ScriptManager runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="panelLinkButton" runat="server" UpdateMode="Conditional">
<triggers>
<asp:AsyncPostBackTrigger ControlID="LinkButton6" EventName="Click" />
</triggers>
<contenttemplate>
<asp:LinkButton ID="LinkButton6" runat="server" CssClass="btn btn-info" OnClick="lnkAddToGroup_Click"><i class="fa fa-search"></i></asp:LinkButton>
</contenttemplate>
</asp:UpdatePanel>
Try using an UpdatePanel like:
<asp:UpdatePanel ID="u1" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="lnt" EventName="Click" />
</Triggers>
<ContentTemplate>
<asp:LinkButton ID="lnt" runat="server" onclick="LinkTest_Clkk">LinkButton</asp:LinkButton>
</ContentTemplate>
</asp:UpdatePanel>

Update panel not working in two asp panel

In my ascx page I have two panel,I trying to change these panels inside an update panel.but the page load is going on each click on radio button.here is my code
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Panel ID="Panel2" runat="server" >
<asp:RadioButtonList runat="server" ID="radioListAnswers" RepeatDirection="Horizontal" AutoPostBack="true" ClientIDMode="Static" onselectedindexchanged="radioListAnswers_SelectedIndexChanged">
</asp:RadioButtonList>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="radioListAnswers" EventName="SelectedIndexChanged"/>
</Triggers>
<ContentTemplate>
<asp:Panel ID="Panel1" runat="server" Visible="false">
<div> Thanks</div>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
here is my code behind
void radioListAnswers_SelectedIndexChanged(object sender, EventArgs e)
{
panel2.Visible=false;
panel1.Visible=true;
}
on click on each radio button the page is reloading.How can we over come this.
Thanks in advance for help.
i hope this will help. Pls check this link
https://msdn.microsoft.com/en-us/library/bb398867(v=vs.140).aspx

upload file not working in updatepanel

I DONT WANNA GET MY PAGE TO BE GET REFRESH OR POSTBACK
So I am trying uploading file in updatepanel but onclicking upload button the validation check shows that there is no file
my html code is
<asp:UpdatePanel ID="UpdatePanel16" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:FileUpload ID="fp_upload" runat="server" />
<asp:Button ID="btn_browse" runat="server" Text="Upload" OnClick="btn_browse_Click" />
</ContentTemplate>
</asp:UpdatePanel>
It seems to be
my .cs code is
protected void btn_browse_Click(object sender, EventArgs e)
{
if (fp_upload.HasFile)
{
Response.Write("contains file");
}
else
{
Response.Write("no file");
}
}
when I used to browse the file and click on upload button every times it goes in else condition. Whats the problem.
ALSO I DONT WANNA GET MY PAGE TO BE GET REFRESH OR POSTBACK
To use a FileUpload control inside an UpdatePanel control, set the postback control that submits the file to be a PostBackTrigger control for the panel.
just add PostBackTrigger after </ContentTemplate> for the FileUploader as below:
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="FileUpload1" />
</Triggers>
</asp:UpdatePanel>
and add the below code in page load :
ScriptManager.GetCurrent(this).RegisterPostBackControl(FileUpload1);
or if you want to make it async, you can use this :
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="btnAsyncUpload" runat="server"
Text="Async_Upload" OnClick = "Async_Upload_File" />
<asp:Button ID="btnUpload" runat="server" Text="Upload"
OnClick = "Upload_File" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID = "btnAsyncUpload"
EventName = "Click" />
<asp:PostBackTrigger ControlID = "btnUpload" />
</Triggers>
</asp:UpdatePanel>
Write trigger will instruct the button that we are using for the upload to perform a full postback
<asp:UpdatePanel ID="UpdatePanel16" runat="server">
<Triggers>
<asp:PostBackTrigger ControlID="btn_browse" />
</Triggers>
<ContentTemplate>
<asp:FileUpload ID="fp_upload" runat="server" />
<asp:Button ID="btn_browse" runat="server" Text="Upload" OnClick="btn_browse_Click" />
</ContentTemplate>
</asp:UpdatePanel>

ASP Button Event not firing into UserControl UpdatePanel

I have a page with an UpdatePanel that calls a UserControl with another UpdatePanel. The LinkButton event into the user control UpdatePanel is not firing.
<asp:UpdatePanel ID="updPost" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="linkComment" EventName="Click" />
</Triggers>
<ContentTemplate>
<asp:LinkButton ID="linkComment" runat="server"
OnClick="linkComment_Click" OnClientClick="return showCommentBox()"
CssClass="PostComment" Text="Comment" />
</ContentTemplate>
</asp:UpdatePanel>
This code is into a usercontrol called in other page update panel.
Anyone can help me?
Thanks
Please show your markup so we can see how your triggers are defined, you should have at least one trigger, something like so:
<Triggers>
<asp:AsyncPostBackTrigger ControlID="MyButton" EventName="Click" />
</Triggers>
Just to clear up the simple stuff, have you included the ScriptManager tag on your page?
i.e. <asp:ScriptManager ID="ScriptManager1" runat="server" />

Label in Update panel does not refreshing

I have a Update panel in Master page, and have a label and button in the content page,, when i click on the button and assign some text to label , the value set to label does not reflect, i think the issue due to update panel in Master page, can anyone help?
In Master Page
<asp:UpdatePanel ID="updatePanel1" runat="server">
<ContentTemplate>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
In Content Page
I solve my Problem, I am posting here may be it will help someone
Add the asp:PostBackTrigger in update panel
<asp:UpdatePanel ID="updatePanel1" runat="server">
<ContentTemplate>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server" />
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="ContentPlaceHolder1" />
</Triggers>
</asp:UpdatePanel>

Categories

Resources