I'm new to ASP.NET and I'm trying to get this Ajax ModalPopupExtender working. This is an example i found on the net, but nothing happens when btnpopup is clicked.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="ModalTestProject._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:scriptmanager id="ScriptManager1" runat="server">
</asp:scriptmanager>
<asp:Button ID="btnpopup" runat="server" Text="Button" />
<ajaxToolkit:ModalPopupExtender ID="mpe" runat="server" TargetControlID="btnpopup" PopupControlID="pnlpopup"
CancelControlID="btnCancelpopup" EnableViewState="true" DropShadow="true" />
<asp:Panel ID="pnlpopup" runat="server" Width="400px">
test
<asp:Button ID="btnCancelpopup" runat="server" Text="Button" />
</asp:Panel>
</form>
</body>
</html>
Make sure your project references 'AjaxControlToolkit.dll'
Make sure your web.confog contains the following section:
Try wrapping the entire thing in an UpdatePanel like so:
Try using ToolkitScriptManager instead of ScriptManager:
I think you are missing the Register directive. You should add something like
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolKit" %
> after the`<%@ Page ... %>' directive
You can show the popup panel with javascript. I'm not sure if there's any other way, but this works like a charm. I used it for a comment control I created.
The control to fire the event:
And lastly, the popup extender and the popup panel. Just change the cc1 prefix to whatever you're using, eg. asp, ajaxtoolkit, etc.
Here's the styles I used, you'll obviously need to change some of them to suit your needs.
I have never ever ever been able to make the popup extender work! Never, regardless of how simple or basic the page or example is, period!
Even this most basic example will not work! Yes, the tool kit is installed! When the button is pressed, nothing happens!
I've wasted more time with this thing then anyone ever should spend! I've made my own custom popup extender which works flawlessly!
You are missing the
PopupControlID="pnlpopup"