MOdalPopupExtender Hiding Problem with Update Panel - asp.net

I have a modalpopupExtender which is opened when edit button is clicked.In that i have a gridview in which if click any row the popup gets hidden and the values are displayed on the page.The problem is that when i keep this code in the update panel the modalpopupextender is not getting hidden after clicking in the gridview.I have a master page in my page and using Ajax modal popup extender

are you doing a full postback? If so, in the Click event why not use ModalPopup.Hide()??

I saw the same behavior what i did was putting modelpopup before update panel that way it worked
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<cc1:ModalPopupExtender ID="mpeScreenFreez"
runat="server"
BackgroundCssClass="modalBackground"
DropShadow="true"
TargetControlID="btnDummy"
PopupControlID="panFreeze">
</cc1:ModalPopupExtender>
<asp:Panel ID="panFreeze" runat="server" CssClass="modalPopup" style="display:none;">
<asp:Label ID="lblSave" runat="server" Font-Bold="true" Text="Sending the Quote....">
</asp:Label>
</asp:Panel>
<asp:Button ID="btnDummy" runat="server" CssClass="hidden" />
<asp:UpdatePanel ID="upDirectHomOwnrPremQuote" runat="server">
<ContentTemplate></ContentTemplate>

Related

change control outside UpdatePanel

In short: I want to enable a button i.e. outside UpdatePanel when I click on a button from inside UpdatePanel.
Problem: The button enables but tags i and asp:Localize are not showing in the rendered code after button click from UpdatePanel updPnlOfferings
Detail:
I have a DataList inside UpdatePanel which contains delete button for every item in the list. delete button is firing an event on server which deletes the record and disables a button (i.e. outside of the UpdatePanel.
As someone suggested I kept my button(which need to be disabled) in UpdatePanel below
<asp:UpdatePanel ID="updPnlCourse" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:LinkButton ID="lnkDeleteCourseDetails" runat="server" OnClick="lnkDeleteCourseDetails_Click">
<i class="icon-remove-sign"></i>
<asp:Localize ID="Localize6" runat="server" Text="<%$ Resources:CBLabels, LBL_DeleteDetails %>" />
</asp:LinkButton>
<asp:ConfirmButtonExtender ID="lnkDeleteCourseDetails_ConfirmButtonExtender" runat="server"
ConfirmText='Are you sure you want to delete this course?' Enabled="True" TargetControlID="lnkDeleteCourseDetails">
</asp:ConfirmButtonExtender>
</ContentTemplate>
</asp:UpdatePanel>
The Main UpdatePanel which is firing the event is below
<asp:UpdatePanel ID="updPnlOfferings" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Panel ID="pnlDSOfferings" runat="server">
<asp:DataList ID="dtlstOfferings" runat="server" OnItemCommand="dtlstOfferings_ItemCommand" EnableViewState="true">
</asp:DataList></asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
on dtlstOfferings_ItemCommand event I coded this
lnkDeleteCourseDetails.Enabled = true;
lnkDeleteCourseDetails.ToolTip = "";
lnkDeleteCourseDetails_ConfirmButtonExtender.Enabled = true;
updPnlCourse.Update();
This is a known problem as specified in this link.
The solution is to put all your content that are there inside the LinkButton, within a place holder like below, or make all the child controls as server controls.
<asp:LinkButton ID="lnkDeleteCourseDetails" runat="server" OnClick="lnkDeleteCourseDetails_Click">
<asp:PlaceHolder runat="server">
<i class="icon-remove-sign"></i>
<asp:Localize ID="Localize6" runat="server" Text="<%$ Resources:CBLabels, LBL_DeleteDetails %>" />
</asp:PlaceHolder>
</asp:LinkButton>

UpdatePanel causing full postback. Trying to do a partial postback

I am working on a page that is using a gridview to display data. I have some dynamically created textboxes inside an ItemTemplate which contains several textboxes per row. Now I also have an update panel that is using ajax and should only render once my link button is clicked. The datalist is bound in my code behind after the I would like this to occur without causing a full postback. However, right now when I click the link button it causes a full post-back which eliminates my dynamically created controls.
I feel I am very close to a solution. I need one of these to happen (option 1 seems more useful):
Do not cause a postback when the linkbutton is clicked, but still render my full datalist in the update panel
or
my dynamically created controls are not removed during post back.
Here is my code:
<ItemTemplate>
[ <asp:LinkButton ID="SelectCommand" CommandName="Select" runat="server" Text="+" CssClass="sunocoBold"/> ]
<%-- start sub panel--%>
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:DataList ID="DataList1" runat="server" RepeatDirection="Vertical"
OnItemCommand="DataList_OnItemCommand">
<ItemTemplate>
<asp:LinkButton ID="Select" CommandName="SelectCommand" CommandArgument='<%#Eval("ship_to_num")%>' runat="server" Text='<%#Eval("ship_to_num")%>' />
</ItemTemplate>
</asp:DataList>
</ContentTemplate>
</asp:UpdatePanel>
<%-- end sub panel--%>
</ItemTemplate>
<asp:TemplateField HeaderText="Site Owner" ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Top">
<ItemTemplate>
<asp:Panel ID="pnlNames" runat="server">
</asp:Panel>
<%-- <asp:Literal ID="NameList" runat="server" /> --%>
</ItemTemplate>
</asp:TemplateField>
UpdatePanel.Triggers is made for this!
Take a look at it here: Understanding UpdatePanel.Triggers

Button onClick event not firing inside a repeater which is in UpdatePanel

I know I am missing something simple but I can't seem to get my button to post back. This is how my form looks (simplified):
<asp:ScriptManager id="smMembersArea" runat="server" EnableViewState="False" />
<asp:UpdatePanel id="updAccounts" runat="server" EnableViewState="True">
<ContentTemplate>
<asp:Repeater id="rptrWishList" runat="server" EnableViewState="False">
<HeaderTemplate></HeaderTemplate>
<ItemTemplate>
<asp:Button id="bWLAmend" onclick="FEdit" runat="server" cssclass="button bg" EnableViewState="True" Text="GO"/>
</ItemTemplate>
<FooterTemplate></FooterTemplate>
</asp:Repeater>
</ContentTemplate>
</asp:UpdatePanel>
The update panel doesn't do anything and nothing happens in FEdit.
When I remove the updatepanel my FEdit event is triggered correctly.
Can anyone point me in the right direction please.
Thanks.
what you can do is add CommandName="Select" to your button
so your button now looks like this
<asp:Button id="bWLAmend" onclick="FEdit" runat="server" cssclass="button bg" EnableViewState="True" Text="GO" CommandName="Select"/>
and use itemcommand of the repeater rptrWishList_ItemCommand
so when you click the button, itemcommand event of repeater fires.
what language you are using in code behind..?I may be able to suggest something else.

HyperLink problem under Panel within UpdatePanel

The HyperLink under Panel within UpdatePanel is not clickable. When HyperLink is moved from sub panel to UpdatePanel, everything is good. Here is my code -
Page:
<asp:UpdatePanel ID="p" runat="server" RenderMode="Inline" UpdateMode="Conditional">
...
<some:UserControl ID="uc" runat="server" />
...
</asp:UpdatePanel>
SomeUserControl:
<asp:Panel ID="p" runat="server">
...
<asp:HyperLink ID="hlExportFile" runat="server" />
...
</asp:Panel>
Would be glad to hear any solution. Thanks ahead!
You Panel needs an ID.

ModalPopupExtender OK Button click event not firing?

I have a Button inside an UpdatePanel. The button is being used as the OK button for a ModalPopupExtender. For some reason, the button click event is not firing. Any ideas? Am I missing something?
<asp:updatepanel id="UpdatePanel1" runat="server">
<ContentTemplate>
<cc1:ModalPopupExtender ID="ModalDialog" runat="server"
TargetControlID="OpenDialogLinkButton"
PopupControlID="ModalDialogPanel" OkControlID="ModalOKButton"
BackgroundCssClass="ModalBackground">
</cc1:ModalPopupExtender>
<asp:Panel ID="ModalDialogPanel" CssClass="ModalPopup" runat="server">
...
<asp:Button ID="ModalOKButton" runat="server" Text="OK"
onclick="ModalOKButton_Click" />
</asp:Panel>
</ContentTemplate>
</asp:updatepanel>
Aspx
<ajax:ModalPopupExtender runat="server" ID="modalPop"
PopupControlID="pnlpopup"
TargetControlID="btnGo"
BackgroundCssClass="modalBackground"
DropShadow="true"
CancelControlID="btnCancel" X="470" Y="300" />
//Codebehind
protected void OkButton_Clicked(object sender, EventArgs e)
{
modalPop.Hide();
//Do something in codebehind
}
And don't set the OK button as OkControlID.
It appears that a button that is used as the OK or CANCEL button for a ModalPopupExtender cannot have a click event. I tested this out by removing the
OkControlID="ModalOKButton"
from the ModalPopupExtender tag, and the button click fires. I'll need to figure out another way to send the data to the server.
It could also be that the button needs to have CausesValidation="false". That worked for me.
I was just searching for a solution for this :)
it appears that you can't have OkControlID assign to a control if you want to that control fires an event, just removing this property I got everything working again.
my code (working):
<asp:Panel ID="pnlResetPanelsView" CssClass="modalPopup" runat="server" Style="display:none;">
<h2>
Warning</h2>
<p>
Do you really want to reset the panels to the default view?</p>
<div style="text-align: center;">
<asp:Button ID="btnResetPanelsViewOK" Width="60" runat="server" Text="Yes"
CssClass="buttonSuperOfficeLayout" OnClick="btnResetPanelsViewOK_Click" />
<asp:Button ID="btnResetPanelsViewCancel" Width="60" runat="server" Text="No" CssClass="buttonSuperOfficeLayout" />
</div>
</asp:Panel>
<ajax:ModalPopupExtender ID="mpeResetPanelsView" runat="server" TargetControlID="btnResetView"
PopupControlID="pnlResetPanelsView" BackgroundCssClass="modalBackground" DropShadow="true"
CancelControlID="btnResetPanelsViewCancel" />
Put into the Button-Control the Attribute "UseSubmitBehavior=false".
None of the previous answers worked for me. I called the postback of the button on the OnOkScript event.
<div>
<cc1:ModalPopupExtender PopupControlID="Panel1"
ID="ModalPopupExtender1"
runat="server" TargetControlID="LinkButton1" OkControlID="Ok"
OnOkScript="__doPostBack('Ok','')">
</cc1:ModalPopupExtender>
<asp:LinkButton ID="LinkButton1" runat="server">LinkButton</asp:LinkButton>
</div>
<asp:Panel ID="Panel1" runat="server">
<asp:Button ID="Ok" runat="server" Text="Ok" onclick="Ok_Click" />
</asp:Panel>
I often use a blank label as the TargetControlID. ex. <asp:Label ID="lblghost" runat="server" Text="" />
I've seen two things that cause the click event not fire:
1. you have to remove the OKControlID (as others have mentioned)
2. If you are using field validators you should add CausesValidation="false" on the button.
Both scenarios behaved the same way for me.
I've found a way to validate a modalpopup without a postback.
In the ModalPopupExtender I set the OnOkScript to a function e.g ValidateBeforePostBack(), then in the function I call Page_ClientValidate for the validation group I want, do a check and if it fails, keep the modalpopup showing. If it passes, I call __doPostBack.
function ValidateBeforePostBack(){
Page_ClientValidate('MyValidationGroupName');
if (Page_IsValid) { __doPostBack('',''); }
else { $find('mpeBehaviourID').show(); }
}

Resources