[英]PageMethods.Method not being called from javascript
I have a javascript function that builds a string then sends the string to the c# codebehind to work with.我有一个 javascript function,它构建一个字符串,然后将该字符串发送到 c# 代码隐藏以供使用。 Problem is, the PageMethods.Method is never being called.
问题是,永远不会调用 PageMethods.Method。
pertinent code:相关代码:
aspx page: 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);
}
codebehind:代码隐藏:
[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);
}
}
I had to enable autopostback on the RadioButtonList for the SelectedIndexChanged method to be hit.我必须在 RadioButtonList 上启用自动回发才能命中 SelectedIndexChanged 方法。 It works for now, but I'll need to figure out something in the future to get past having to post back.
它现在有效,但我需要在未来想出一些办法来避免不得不回发。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.