ASP.NET 中的 AjaxControlToolkit 问题

发布于 2024-10-30 08:44:12 字数 2092 浏览 0 评论 0原文

我正在尝试设置 ajaxConfirmButton Extender。这是我的代码

    <%@ 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>

后面的代码

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

但是确认窗口没有出现。它只是执行 onclick 操作。需要帮助来解决这个问题

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?
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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你怎么这么可爱啊 2024-11-06 08:44:12

您需要使用 ToolkitScriptManager 而不是 ScriptManager。

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

希望它能帮助你

You need to use ToolkitScriptManager instead of ScriptManager.

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

Hope it will help you

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文