views:

547

answers:

3

Hi, 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"&gt;

<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>
A: 

I've tested provided code, everything seems to work except you should write ScriptManager not scriptmanager, case matters.

Try another AJAX features, maybe it's not installed correctly.

GregoryM
A: 

I think you are missing the Register directive. You should add something like

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolKit" %> after the

`<%@ Page ... %>' directive

Nikos Steiakakis
A: 

Make sure your project references 'AjaxControlToolkit.dll'

Make sure your web.confog contains the following section:

<controls>
<add namespace="AjaxControlToolkit" assembly="AjaxControlToolkit" tagPrefix="ajaxToolkit"/>
...
</controls>

Try wrapping the entire thing in an UpdatePanel like so:

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="btnpopup" runat="server" Text="Button" /> 

<ajaxToolkit:ModalPopupExtender ID="mpe" runat="server" TargetControlID="btnpopup" PopupControlID="pnlpopup" 
    CancelControlID="btnCancelpopup" EnableViewState="true" />

<asp:Panel ID="pnlpopup" runat="server">
    test
    <asp:Button ID="btnCancelpopup" runat="server" Text="Button" />
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
edosoft