我想显示来自服务器端的确认消息,然后显示“确定”或“取消”我想执行服务器端方法的事件

发布于 2024-11-02 14:51:10 字数 1892 浏览 0 评论 0原文

我有一个像这样的按钮:-

<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>  
    <telerik:RadAjaxPanel ID="mainAjaxPanelContentManager" runat="server" Height="100%" LoadingPanelID="contentManagerRadAjaxLoadingPanel" OnAjaxRequest="ContentManagerAjaxRequest"></telerik:RadAjaxPanel>


<asp:ImageButton ID="btnadd" runat="server" ImageUrl="~/Images/Done.png" 
        Height="20px" OnClientClick="test()"/>

然后我有这样的 javascript 函数:-

function test() 
{
    var result;
    var r = confirm("Duplicate Serial Number - DO you want to change it?");
    $find("<%= mainAjaxPanelContentManager.ClientID %>").ajaxRequest(r);    
}

它成功运行以下服务器端方法:-

protected void ContentManagerAjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)
    {
        if (e.Argument.ToLower() == "true")
        {
        }
    }

但是当我这样做时:-

<asp:ImageButton ID="btnadd" runat="server" ImageUrl="~/Images/Done.png" 
        Height="20px" OnClick="btnadd_Click"/>

protected void btnadd_Click(object sender, ImageClickEventArgs e)
    {
        showMessageBox("Hello");
    }

    protected void showMessageBox(string message)
    {
        string sScript = "";
        sScript += "var result;";
        sScript += "var r = confirm('Duplicate Serial Number - DO you want to change it');";       
        sScript += mainAjaxPanelContentManager + ".ajaxRequest(r);";


        ScriptManager.RegisterStartupScript(this, this.GetType(), "confirm", sScript, true);


    }

那么它不会执行服务器端方法 ContentManagerAjaxRequest 和抛出“对象不支持此属性或方法”的异常。

我认为服务器端不支持ajaxRequest()。但它的替代品是什么?

实际上我的问题是我想显示来自服务器端的确认消息,然后在“确定”或“取消”事件上我想执行服务器端方法,例如“ContentManagerAjaxRequest

I have a button like this:-

<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>  
    <telerik:RadAjaxPanel ID="mainAjaxPanelContentManager" runat="server" Height="100%" LoadingPanelID="contentManagerRadAjaxLoadingPanel" OnAjaxRequest="ContentManagerAjaxRequest"></telerik:RadAjaxPanel>


<asp:ImageButton ID="btnadd" runat="server" ImageUrl="~/Images/Done.png" 
        Height="20px" OnClientClick="test()"/>

then i have javascript function like this:-

function test() 
{
    var result;
    var r = confirm("Duplicate Serial Number - DO you want to change it?");
    $find("<%= mainAjaxPanelContentManager.ClientID %>").ajaxRequest(r);    
}

which successfully runs following server side method:-

protected void ContentManagerAjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)
    {
        if (e.Argument.ToLower() == "true")
        {
        }
    }

But when i do like this:-

<asp:ImageButton ID="btnadd" runat="server" ImageUrl="~/Images/Done.png" 
        Height="20px" OnClick="btnadd_Click"/>

protected void btnadd_Click(object sender, ImageClickEventArgs e)
    {
        showMessageBox("Hello");
    }

    protected void showMessageBox(string message)
    {
        string sScript = "";
        sScript += "var result;";
        sScript += "var r = confirm('Duplicate Serial Number - DO you want to change it');";       
        sScript += mainAjaxPanelContentManager + ".ajaxRequest(r);";


        ScriptManager.RegisterStartupScript(this, this.GetType(), "confirm", sScript, true);


    }

then it not execute server side method ContentManagerAjaxRequest and throws an exception that "Object doesn't support this property or method".

i think ajaxRequest() not supported on serverside. but wahts is its alter native?

actually my problem is that i want to show the confirm message from the server side then on the "OK" or "Cancel" event i want to execute a server side method like "ContentManagerAjaxRequest"

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

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

发布评论

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

评论(1

笑咖 2024-11-09 14:51:10
sScript += mainAjaxPanelContentManager + ".ajaxRequest(r);";

那应该做什么?

难道你不想要这样的东西吗(你一开始就已经这么做了)?

sScript += mainAjaxPanelContentManager.ClientID + ".ajaxRequest(r);";
sScript += mainAjaxPanelContentManager + ".ajaxRequest(r);";

What is that supposed to do?

Don't you want something like this (which you already did in the beginning)?

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