Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Friday, September 27, 2013 5:07 AM
Hi all,
I'm making a popup window in my application with ModalPOpupextender but it is showing error that "ModalPopExtender is not a known element"
How to fix it???
All replies (9)
Friday, September 27, 2013 8:22 AM âś…Answered
<tr>
<td colspan="2">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
</td>
</tr>
<tr>
<td style="height: 10px" colspan="2">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<tr>
<td colspan="2">
<asp:Button ID="btnChkDup" runat="server" CssClass="button_text_login" Text="CheckDuplicate" Width="146px" BackColor="#3399FF" Font-Names="Arial Black" OnClick="btnChkDup_Click" />
</td>
</tr>
<asp:Panel ID="pnlModal" runat="server">
<asp:GridView ID="GridView1" runat="server" CssClass="gridviewrow_na">
</asp:GridView>
<asp:Button ID="btnClose" runat="server" Text="X" Font-Bold="true" Width="40px" CssClass="button" BackColor="Red" BorderColor="Black" />
</asp:Panel>
<asp:LinkButton ID="lnkFake1" runat="server"></asp:LinkButton>
<cc1:ModalPopupExtender TargetControlID="lnkFake1" ID="pnlModal_ModalPopupExtender"runat="server" BackgroundCssClass="modalBackground"
PopupControlID="pnlModal" CancelControlID="btnClose">
</cc1:ModalPopupExtender>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
and write this.pnlModal_ModalPopupExtender.Show() in btnChkDup_Click event.
Friday, September 27, 2013 5:09 AM
Hi
Please follow this tutorial
Friday, September 27, 2013 5:26 AM
http://www.dotnetcurry.com/ShowArticle.aspx?ID=285
I've read this article and did exactly what they have said but I can't find any smart tag near my update panel so I don't know how to add extender.
Friday, September 27, 2013 5:41 AM
I suggest you to try the link I have posted as it is 100% working with a demo. Meanwhile I will try in your way.
Friday, September 27, 2013 6:36 AM
How to put grid view in a popup ??? Do you have any idea???
Friday, September 27, 2013 6:43 AM
In a scenario where you set a modal popups
TargetControlId
to a dummy field you have to explicitly call
ModalPopupExtender1.Show();
to display the modal.
Tip - using a button for a dummy field is a bit of an overkill, use something simple like a
<span>
instead
Below is a working example if you get stuck, but I believe calling
ModalPopupExtender1.Show();
should sort you out:
ASPX:
<form id="form1" runat="server">
<asp:ToolkitScriptManager ID="sm" runat="server">
</asp:ToolkitScriptManager>
<span ID="dummy" runat="server" />
Post code: <asp:TextBox ID="txtPostcode" runat="server" /><br />
<asp:Button ID="btnSearch" runat="server" Text="Search" OnClick="Search" />
<asp:Panel runat="server" ID="modalPanel" CssClass="modalPanel">
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
<asp:Button ID="btnCancel" runat="server" Text="Cancel" />
</asp:Panel>
<asp:ModalPopupExtender id="ModalPopupExtender1" runat="server" TargetControlID="dummy"
PopupControlID="modalPanel" BackgroundCssClass="ModalBackground"
CancelControlID="btnCancel" BehaviorID="ModalGrid">
</asp:ModalPopupExtender>
</form>
Code behind:
protected void Search(object sender, EventArgs e)
{
List<PostalCode> codes = new List<PostalCode>()
{
new PostalCode{ Code="000",Province="District 0" },
new PostalCode{ Code="111",Province="District 1" }
};
string code = txtPostcode.Text;
if (codes.Where(c => c.Code == code).Any())
{
GridView1.DataSource = codes.Where(c => c.Code == code);
GridView1.DataBind();
ModalPopupExtender1.Show();
}
}
Class I've used for testing:
public class PostalCode
{
public string Code { get; set; }
public string Province { get; set; }
}
**
**
Friday, September 27, 2013 8:12 AM
This is My code which I wrote... But it is not showing gridView :(
<tr>
<td colspan="2">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
</td>
</tr>
<tr>
<td style="height: 10px" colspan="2">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<tr>
<td colspan="2">
<asp:Button ID="btnChkDup" runat="server" CssClass="button_text_login" Text="CheckDuplicate" Width="146px" BackColor="#3399FF" Font-Names="Arial Black" OnClick="btnChkDup_Click" />
</td>
</tr>
<asp:Panel ID="pnlModal" runat="server">
<asp:GridView ID="GridView1" runat="server" CssClass="gridviewrow_na">
</asp:GridView>
<asp:Button ID="btnClose" runat="server" Text="X" Font-Bold="true" Width="40px" CssClass="button" BackColor="Red" BorderColor="Black" />
</asp:Panel>
<cc1:ModalPopupExtender TargetControlID="btnChkDup" ID="pnlModal_ModalPopupExtender"runat="server" BackgroundCssClass="modalBackground"
PopupControlID="pnlModal" CancelControlID="btnClose">
</cc1:ModalPopupExtender>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
Friday, September 27, 2013 8:18 AM
Have you used pnlModal_ModalPopupExtender.Show() in btnChkDup_Click event??
Sunday, September 29, 2013 11:36 PM
Maybe these links help:
http://www.andreas-kraus.net/blog/ajax-element-scriptmanager-is-not-a-known-element/