服务器端代码无法从javascript访问-reg [英] Server side code could not access from javascript - reg
本文介绍了服务器端代码无法从javascript访问-reg的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的所有人,
我无法从javascript访问服务端方法.我在这里放置了代码
Dear All,
I could not access service side method from javascript. Here i placed my code
ShowTable = function()
{
var Obj= $get('pid').value;
PageMethods.GivemeContent(Obj,OnSuccess)
alert(Obj);
}
OnSuccess= function(result)
{
var Obj= $get('mydiv');
Obj.innerHTML=result;
}
服务器端:
server side:
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public static string GivemeContent(string value)
{
return @"DemoString";
}
<ajax:ScriptManager ID="ScriptManager1" runat="server"
EnablePageMethods="true" EnablePartialRendering="true">
</ajax:ScriptManager>
<ajax:UpdatePanel ID="myupdatePanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div>
Your Name :
<asp:TextBox ID="pid" runat="server" ></asp:TextBox>
<input id="btn" type="button" value="Show Table" onclick="ShowTable()"/>
</div>
<div id="mydiv" runat="server">
</div>
</ContentTemplate>
</ajax:UpdatePanel>
推荐答案
get(' pid' ).value; PageMethods.GivemeContent(Obj,OnSuccess) 警报(Obj); } OnSuccess = 功能(结果) { var Obj =
get('pid').value; PageMethods.GivemeContent(Obj,OnSuccess) alert(Obj); } OnSuccess= function(result) { var Obj=
get('
get('mydiv'); Obj.innerHTML=result; }
服务器端:
server side:
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public static string GivemeContent(string value)
{
return @"DemoString";
}
<ajax:ScriptManager ID="ScriptManager1" runat="server"
EnablePageMethods="true" EnablePartialRendering="true">
</ajax:ScriptManager>
<ajax:UpdatePanel ID="myupdatePanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div>
Your Name :
<asp:TextBox ID="pid" runat="server" ></asp:TextBox>
<input id="btn" type="button" value="Show Table" onclick="ShowTable()"/>
</div>
<div id="mydiv" runat="server">
</div>
</ContentTemplate>
</ajax:UpdatePanel>
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</httpModules>
我寻找到了自我.如果在网络配置文件中添加了这些行.它正在工作
I Found myself. if added these lines in web config file. it is working
这篇关于服务器端代码无法从javascript访问-reg的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文