PageMethods.Method没有从javascript调用

时间:2012-04-05 21:36:35

标签: c# asp.net scriptmanager pagemethods

我有一个构建字符串的javascript函数,然后将字符串发送到c#codebehind来使用。问题是,PageMethods.Method永远不会被调用。

相关代码:

aspx页面:

<asp:ScriptManager ID="ScriptManager1" EnablePageMethods="true" EnablePartialRendering="true"
    runat="server" />
<script type="text/javascript">
function makeString() {
        debugger
        var a = document.getElementById("ddlRptYear").value + "_";
        var b = document.getElementById("ddlRptType").value + "_";
        var c = document.getElementById("ddlGeography").value + "_";
        var d = "";
        var e = "";
        var x = document.getElementById("ddlTouchPoint");
        var y = document.getElementById("ddlAOR");

        if (x.disabled == false) {
            d = x.value + "_";
        }

        if (y.disabled == false) {
            e = y.value;
        }

        var pptString = a + b + c + d + e + ".ppt";
        PageMethods.GetPPTString(pptString, onSuccess, onFail);
    }

代码隐藏:

[System.Web.Services.WebMethod]
    public static void GetPPTString(string pptString)
    {
        if ((pptString == "") || (pptString == null))
        {
            throw new Exception("Error: No String Sent.");
        }
        else
        {
            throw new Exception(pptString);
        }
    }

1 个答案:

答案 0 :(得分:0)

我必须在RadioButtonList上启用autopostback才能命中SelectedIndexChanged方法。它现在有效,但我需要弄清楚将来必须发布回来的东西。