Wednesday, March 21, 2012

December Release WebMethod problems

I have downloaded the December release and included all of the .js files and Atlas dll. But now the code that I wrote with the October release fails. The code is not complicated.

<%@dotnet.itags.org.PageLanguage="C#"AutoEventWireup="true"CodeFile="test2.aspx.cs"Inherits="test2" %>

<%@dotnet.itags.org.ImportNamespace="System.Web.Services" %>

<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">

<headrunat="server">

<title>Web Method on Page</title>

<atlas:ScriptManagerID="ScriptManager1"runat="server"/>

<scripttype="text/C#"runat="server">

[WebMethod]

publicstring HelloWorld(string s)

{

Session["a"] ="a";

return"Hello '" + s +"'";

}

</script>

</head>

<body>

<formid="Form1"runat="server">

Enter your name:

<asp:TextBoxid="nameTextBox"runat="server"></asp:TextBox>

<buttonid="buttonGo"onclick="return OnbuttonGo_click()">GO</button>

</form>

<scripttype="text/javascript"language="JavaScript">

function OnbuttonGo_click()

{

//textbox string value passed as a param to the server method

PageMethods.HelloWorld(document.getElementById("nameTextBox").value, OnWebRequestComplete1);

returnfalse;

}

function OnWebRequestComplete1(result)

{

alert(result);

}

</script>

</body>

</html>

I always get the js following js errors 'Web in not defined'

When I view source I get the following, and ideas?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">


<head><title>
Web Method on Page
</title><link href="http://links.10026.com/?link=App_Themes/IFMS/ControlStyles.css" type="text/css" rel="stylesheet" /><link href="http://links.10026.com/?link=App_Themes/IFMS/StyleSheet.css" type="text/css" rel="stylesheet" /></head>
<body>
<form name="Form1" method="post" action="test2.aspx" id="Form1">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTU3MTQ0NjYwNmRkbD9DWJ65Ak0fRi4Rp1uhlAFON/k=" />
</div>


<script src="http://pics.10026.com/?src=ScriptLibrary/Atlas/Debug/Atlas.js" type="text/javascript"></script>
Enter your name:
<input name="nameTextBox" type="text" id="nameTextBox" class="textBox widthMedium" />
<button id="buttonGo" onclick="return OnbuttonGo_click()" >GO</button>


<script type="text/xml-script"><page xmlns:script="http://schemas.microsoft.com/xml-script/2005">
<components />
</page></script><script type="text/javascript">var PageMethods = new function() {
var cm=Web.Net.PageMethodRequest.createProxyMethod;
cm(this,"HelloWorld","s");
}

</script></form>

<script type="text/javascript" language="JavaScript">
function OnbuttonGo_click()
{
//textbox string value passed as a param to the server method
//PageMethods.HelloWorld(document.getElementById("nameTextBox").value, OnWebRequestComplete1);
//return false;
}

function OnWebRequestComplete1(result)
{
alert(result);
}
</script>

</body>
</html>

Maybe you should write your web method in your code-behind file...

i have tried this code .

it's worked


I have actually tried putting my code in the code-behind and still get the error. I think the error is coming from the following line

var cm=Web.Net.PageMethodRequest.createProxyMethod

I did not create a new project, but instead have tried to upgrade my old project that used the October release.

Is there any documentation that outlines how to properly update your code from the October release to the December release? The way I figured out how to set up my project was to create an new web site and selected the AJAX template to find out where to put all the new .js files and how to set up my web.config.


I'm getting the same thing. I believe it's because of a "js" include that I'm missing. Let me know if you find the solution.

Here's how I did the includes (Inside a master page).

<headid="Head1"runat="server">

<scriptlanguage="JScript"src="../home/common/generic.js"></script>

<scriptlanguage="VBScript"src="../home/common/generic.vbs"></script>

<atlas:ScriptManagerID="ScriptManager1"runat="server"EnablePartialRendering=trueEnableScriptComponents=true>
<Scripts>
<atlas:ScriptReferencePath="../home/common/ReleaseAtlas.js"/>
<atlas:ScriptReferencePath="../home/common/ReleaseAtlasCompat.js"/>
<atlas:ScriptReferencePath="../home/common/ReleaseAtlasCompat2.js"/>
<atlas:ScriptReferencePath="../home/common/ReleaseAtlasRunTime.js"/>
<atlas:ScriptReferencePath="../home/common/ReleaseAtlasUIDragDrop.js"/>
<atlas:ScriptReferencePath="../home/common/ReleaseAtlasUIGlitz.js"/>
<atlas:ScriptReferencePath="../home/common/ReleaseAtlasUIMap.js"/>
<atlas:ScriptReferencePath="../home/common/DebugAtlas.js"/>
<atlas:ScriptReferencePath="../home/common/DebugAtlasCompat.js"/>
<atlas:ScriptReferencePath="../home/common/DebugAtlasCompat2.js"/>
<atlas:ScriptReferencePath="../home/common/DebugAtlasRunTime.js"/>
<atlas:ScriptReferencePath="../home/common/DebugAtlasUIDragDrop.js"/>
<atlas:ScriptReferencePath="../home/common/DebugAtlasUIGlitz.js"/>
<atlas:ScriptReferencePath="../home/common/DebugAtlasUIMap.js"/>
<atlas:ScriptReferencePath="../home/common/DefinitionOver.js"/>
<atlas:ScriptReferencePath="../home/common/Definitions.js"/>
</Scripts>
</atlas:ScriptManager>
<linkhref="../home/common/portal.css"rel="stylesheet"type="text/css"/>
</head>

No comments:

Post a Comment