我的功能
<script type="text/javascript">
function methodtocall(id) {
// My code
}
</script>
我的ashx页面
public class sampleClass : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
// here i need to call that method
}
}
是的,我提到了net.But没有解决方案。他们主要提供从方法调用到ashx或从ajax调用的解决方案。
谁能用正确的东西指引我?
像这样指,
ClientScript.RegisterStartupScript(this.GetType(), "methodtocall", script, true);
按照代码,
public class sampleClass : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
var id = "someid"; //implement the id that you want to pass to the Javascript function
ClientScript.RegisterStartupScript(this.GetType(), "methodtocall", id, true);
}
}
希望这可以帮助..!
参考链接:Link