Kanishka
Kanishka

Reputation: 1147

AjaxControlToolkit problem in asp.net

I am trying to set up ajaxConfirmButton Extender. Here is my code

    <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<!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">
    <div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<script language="javascript" type="text/javascript">
    function onCancel()
    {
        var lblMsg = $get('<%=lblMessage.ClientID%>');
        lblMsg.innerHTML = "You clicked the <b>Cancel</b> button of AJAX confirm.";
    }
</script>

<asp:Label ID="Label1" runat="server" Text="Click this button to open AJAX Confirm box:" Font-Bold="true" Font-Size="16px"></asp:Label><br />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <asp:Button ID="btnConfirm" runat="server" Text="Confirm" OnClick="btnConfirm_Click" />
        <ajaxToolkit:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server" TargetControlID="btnConfirm"
            ConfirmText="Are you sure?&#10;You want to run the server code." OnClientCancel="onCancel" ConfirmOnFormSubmit="false">
        </ajaxToolkit:ConfirmButtonExtender>

        <asp:Label ID="lblMessage" runat="server"></asp:Label><br />
    </ContentTemplate>
</asp:UpdatePanel>

</div>

    </form>
</body>
</html>

code behind

 protected void btnConfirm_Click(object sender, EventArgs e)
    {
        lblMessage.Text = "You clicked the <b>OK</b> button of AJAX confirm";
    }

But the confirm wondow is not coming. It is just performing the onclick action. Need help to fix this problem

Upvotes: 0

Views: 525

Answers (1)

Hukam
Hukam

Reputation: 1026

You need to use ToolkitScriptManager instead of ScriptManager.

<ajaxToolkit:ToolkitScriptManager ID="ToolKitScriptManager1" runat="server">
    </ajaxToolkit:ToolkitScriptManager>

Hope it will help you

Upvotes: 1

Related Questions