JS调用后台c#代码的问题
路过的朋友好。
遇到一问题,头都大了,关于JS调用C#后台代码的。下面我贴出来,还望路过的朋友请教下:
AjaxPro.dll
配置文件:
<system.web>
     <httpHandlers>
        <add verb="*" path="ajaxpro/*.ashx" type="AjaxPro.AjaxHandlerFactory,AjaxPro"/>
     </httpHandlers>
</system.web>
c#代码:
public partial class Default2 : System.Web.UI.Page
{
     protected void Page_Load(object sender, EventArgs e)
     {
         AjaxPro.Utility.RegisterTypeForAjax(typeof(Default2));
     }
     [AjaxPro.AjaxMethod]
     public string onChanged()
     {
         return "aaa";
     }
}
前面代码:
<head runat="server">
     <title></title>
     <script type="text/javascript">
         function getAjax() {
             alert(Default2.onChanged());
         }
     </script>
</head>
<body>
     <form id="form1" runat="server">
     <div>
         <input id="Button1" type="button" value="button" onclick="getAjax()"/></div>
     </form>
</body>
就这点东西,调用是总是提示找不到对象“Default2”。
------解决方案--------------------http://apps.hi.baidu.com/share/detail/21698068
------解决方案--------------------把你的js从header里拿出来试试.看你的header有runat
------解决方案--------------------AjaxPro添加到页面没有 。
JS报错没有 。
------解决方案--------------------