0

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

相关代码:

页面:

<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);
        }
    }
4

1 回答 1

0

我必须在 RadioButtonList 上启用自动回发才能命中 SelectedIndexChanged 方法。它现在有效,但我需要在未来找出一些东西来克服不得不发回的问题。

于 2012-04-12T13:12:52.427 回答