通过javascript访问后台代码的功能. [英] Access function of codebehind through javascript.
本文介绍了通过javascript访问后台代码的功能.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已将Java脚本的函数声明为
Hi,
I have declare a function of java script as
<script type="text/javascript">
function Create_New_control()
{
PageMethod.Create_New_Instance();
}
</script>
我想在文本框模糊时调用它,所以我在.cs文件中将其称为
txt_comments.Attributes ["onblur"] ="Create_New_control()";
我在cs文件中的功能定义为
I want call this on blur of textbox so i calls it in .cs file as
txt_comments.Attributes["onblur"] = "Create_New_control()";
And my Function in cs file is defined as
[System.Web.Services.WebMethod]
public static void Create_New_Instance()
{
// Statements
}
但是"Microsoft JScript运行时错误:"PageMethod"未定义"此错误在运行时发生.
因此,我现在需要做些什么来解决此错误.
请给我建议.
在此先感谢.
But "Microsoft JScript runtime error: ''PageMethod'' is undefined" this error occurs at runtime.
So how i need to do now to resolve this error.
Please suggest me.
Thanks in advance.
推荐答案
其PageMethods
不是PageMethod
.另外,您是否尝试过在ScriptManager中进行设置?EnablePageMethods="true"
?
ItsPageMethods
notPageMethod
. Also, have you tried setting this in your ScriptManager?EnablePageMethods="true"
?
您是否在ScriptManager中启用了页面方法?启用它,然后重试..
Did you enable the pagemethod in the ScriptManager? Enable it and then try again..
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
</asp:ScriptManager>
这篇关于通过javascript访问后台代码的功能.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文