Reputation: 27996
I have an asp.net page with ajax updatepanel and a grid. inside the same updatepanel, I have a modalpopupextender. I want to show modalpopupextender on click of the row button of grid.
I have written this js:
function AddRemoveFavorites(regId) {
Showpopup();
return false;
}
function Hidepopup() {
$find('ModalPopupExtender1').hide();
}
//Function to Show ModalPopUp
function Showpopup() {
$find('ModalPopupExtender1').show();
}
and here is markup for update panel, modalpopup and gridview button column.
<asp:UpdatePanel ID="ResultUpdatePanel" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="SearchLinkButton" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="SubmitButton" EventName="Click" />
</Triggers>
<ContentTemplate>
<asp:Button ID="Button1" runat="server" Text="Button" />
<ajax:ModalPopupExtender ID="ModalPopupExtender1" runat="server" CancelControlID="btnCancel"
OkControlID="btnOkay" TargetControlID="Button1" PopupControlID="Panel1" PopupDragHandleControlID="PopupHeader"
Drag="true" BackgroundCssClass="ModalPopupBG">
</ajax:ModalPopupExtender>
<asp:Panel ID="Panel1" Style="display: none" runat="server">
<div class="HellowWorldPopup">
<div class="PopupHeader" id="PopupHeader">
Header</div>
<div class="PopupBody">
<p>
This is a simple modal dialog</p>
</div>
<div class="Controls">
<input id="btnOkay" type="button" value="Done" />
<input id="btnCancel" type="button" value="Cancel" />
</div>
</div>
</asp:Panel>
and grid column
<asp:TemplateField HeaderStyle-CssClass="gridTitleCor2" ItemStyle-CssClass="GridBorderR"
ItemStyle-Wrap="false">
<ItemTemplate>
<asp:PlaceHolder ID="SavedPH" runat="server" Visible='<%# Eval("IsSaved").ToString() == "1" %>'>
<a href='#' onclick='AddRemoveFavorites(<%# Eval("RegistrantID").ToString() %>); return false;'
title="<%= Resources.UserProfile.C_SerRes_RemoveFavorites %>">
<img id='<%# String.Format("StatusImage_{0}", Eval("RegistrantID").ToString()) %>'
src="/Images/StarYellow.png" />
</a></asp:PlaceHolder>
<asp:PlaceHolder ID="NotSavedPH" runat="server" Visible='<%# Eval("IsSaved").ToString() == "0" %>'>
<a href='#' onclick='AddRemoveFavorites(<%# Eval("RegistrantID").ToString() %>); return false;'
title="<%= Resources.UserProfile.C_SerRes_AddFavorites %>">
<img id='<%# String.Format("StatusImage_{0}", Eval("RegistrantID").ToString()) %>'
src="/Images/StarGrey.png" />
</a></asp:PlaceHolder>
</ItemTemplate>
</asp:TemplateField>
but I am getting following error:
Uncaught TypeError: Cannot call method 'show' of null
Upvotes: 1
Views: 13232
Reputation: 39
I assume you have solve the issue.
I think what you are missing is on your ModalPopupExtender is BehaviorID="mpe", then in your javascript you will use $find('mpe').show();
Upvotes: 0
Reputation: 27996
I found answer here:
http://www.jonathanjungman.com/blog/post/Hiding-ASPNET-Ajax-Modal-Popup-Dialog-Using-JavaScript.aspx
Hope it will help someone at some time
Upvotes: 2