开发者

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

开发者 https://www.devze.com 2023-02-27 01:54 出处:网络
I have a button like this:- <telerik:RadScriptManager ID=\"RadScriptManager1\" runat=\"server\">

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 ser开发者_如何学Cver 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"


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);";
0

精彩评论

暂无评论...
验证码 换一张
取 消