| View previous topic :: View next topic |
| Message |
|
Author
|
jceddy
Newbie
|
Joined: 19 Jul 2006
Posts: 20
|
|
Posted: Wed Jul 19, 2006 4:00 am
Post subject: Newbie trying to get started... |
|
|
Okay, I have just begun trying to use this thing, and have been trying to get the simple "GetServerTime" example to work.
(By the way, if someone has a more step-by-step example of how to set up and run AjaxPro than what is available on the web page, it would be nice.)
Anyway, I'm using Visual Studio .NET 2003, .NET Framework 1.1
I've created a new C# Web Application, and added a reference to AjaxPro to it.
I have a WebForm1.aspx file that looks like this:
-------
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs"
AutoEventWireup="false" Inherits="MyDemo.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
<script language="javascript" src="WebForm1.js"></script>
</head>
<body MS_POSITIONING="GridLayout" onload="getServerTime();">
<form id="Form1" method="post" runat="server">
</form>
</body>
</html>
-------
I have a WebForm1.aspx.cs file that looks like this:
-------
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace MyDemo
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
AjaxPro.Utility.RegisterTypeForAjax(typeof(MyDemo.WebForm1));
}
[AjaxPro.AjaxMethod]
public DateTime GetServerTime()
{
return DateTime.Now;
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
-------
I have a Web.config file that looks like this:
-------
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<httpHandlers>
<add verb="POST,GET" path="ajaxpro/*ashx"
type="AjaxPro.AjaxHandlerFactory, AjaxPro"/>
</httpHandlers>
<!-- DYNAMIC DEBUG COMPILATION
Set compilation debug="true" to enable ASPX debugging.
Otherwise, setting this value to
false will improve runtime performance of this application.
Set compilation debug="true" to insert debugging symbols
(.pdb information)
into the compiled page. Because this creates a larger file that executes
more slowly, you should set this value to true only when debugging and to
false at all other times. For more information, refer to the documentation about
debugging ASP.NET files.
-->
<compilation
defaultLanguage="c#"
debug="true"
/>
<!-- CUSTOM ERROR MESSAGES
Set customErrors mode="On" or "RemoteOnly" to enable custom error messages, "Off" to disable.
Add <error> tags for each of the errors you want to handle.
"On" Always display custom (friendly) messages.
"Off" Always display detailed ASP.NET error information.
"RemoteOnly" Display custom (friendly) messages only to users not running
on the local Web server. This setting is recommended for security purposes, so
that you do not display application detail information to remote clients.
-->
<customErrors
mode="RemoteOnly"
/>
<!-- AUTHENTICATION
This section sets the authentication policies of the application. Possible modes are "Windows",
"Forms", "Passport" and "None"
"None" No authentication is performed.
"Windows" IIS performs authentication (Basic, Digest, or Integrated Windows) according to
its settings for the application. Anonymous access must be disabled in IIS.
"Forms" You provide a custom form (Web page) for users to enter their credentials, and then
you authenticate them in your application. A user credential token is stored in a cookie.
"Passport" Authentication is performed via a centralized authentication service provided
by Microsoft that offers a single logon and core profile services for member sites.
-->
<authentication mode="Windows" />
<!-- AUTHORIZATION
This section sets the authorization policies of the application. You can allow or deny access
to application resources by user or role. Wildcards: "*" mean everyone, "?" means anonymous
(unauthenticated) users.
-->
<authorization>
<allow users="*" /> <!-- Allow all users -->
<!-- <allow users="[comma separated list of users]"
roles="[comma separated list of roles]"/>
<deny users="[comma separated list of users]"
roles="[comma separated list of roles]"/>
-->
</authorization>
<!-- APPLICATION-LEVEL TRACE LOGGING
Application-level tracing enables trace log output for every page within an application.
Set trace enabled="true" to enable application trace logging.
If pageOutput="true", the
trace information will be displayed at the bottom of each page. Otherwise, you can view the
application trace log by browsing the "trace.axd" page from your web application
root.
-->
<trace
enabled="false"
requestLimit="10"
pageOutput="false"
traceMode="SortByTime"
localOnly="true"
/>
<!-- SESSION STATE SETTINGS
By default ASP.NET uses cookies to identify which requests belong to a particular session.
If cookies are not available, a session can be tracked by adding a session identifier to the URL.
To disable cookies, set sessionState cookieless="true".
-->
<sessionState
mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
cookieless="false"
timeout="20"
/>
<!-- GLOBALIZATION
This section sets the globalization settings of the application.
-->
<globalization
requestEncoding="utf-8"
responseEncoding="utf-8"
/>
</system.web>
</configuration>
-------
And I have a WebForm1.js file that looks like this:
-------
function getServerTime()
{
MyDemo.WebForm1.GetServerTime(getServerTime_callback); //
asynchronous call
}
// This method will be called after the method has been executed
// and the result has been sent to the client.
function getServerTime_callback(res)
{
alert(res.value);
}
-------
When I run the web page in IE (at http://localhost/MyDemo/WebForm1.aspx) on my machine, it loads with the following JavaScript error:
-------
Line: 4 Char: 3 Error: 'MyDemo' is undefined Code: 0 URL: http://localhost/MyDemo/WebFrom1.aspx
-------
If I View Source on the page that is generated in the browser, I see this:
-------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
<script language="javascript" src="WebForm1.js"></script>
</head>
<body MS_POSITIONING="GridLayout" onload="getServerTime();">
<form name="Form1" method="post" action="WebForm1.aspx" id="Form1">
<input type="hidden" name="__VIEWSTATE"
value="dDwtNjU0MzcyMTk1Ozs+LRnX+0ZFY9n02Hh8L2v1AYyW38w=" />
<script type="text/javascript"
src="/MyDemo/ajaxpro/prototype.ashx"></script>
<script type="text/javascript"
src="/MyDemo/ajaxpro/core.ashx"></script>
<script type="text/javascript"
src="/MyDemo/ajaxpro/converter.ashx"></script>
<script type="text/javascript"
src="/MyDemo/ajaxpro/MyDemo.WebForm1,MyDemo.ashx"></script>
</form>
</body>
</html>
-------
The only thing that I can figure is that the files pointed to by the first three JavaScript includes aren't actually there...although I haven't seen anywhere on any of the "Quick Start" guides associated with AjaxPro that talks about setting these up, and none of the downloads I've downloaded (6.7.11.1_DLL, AjaxPro.6.2.16.1,
AjaxProStarterKit-1076) seem to include those files.
So...I suspect that my problem has something to do with something I missed while setting it up, but there doesn't seem to be a sufficiently detailed set-up guide so I can tell if that's the case or not.
Any help?
Cheers,
Joe
|
| Back to top |
|
 |
|
Author
|
JosephGuadagno
Newbie
|
Joined: 11 Jul 2006
Posts: 49
|
|
Posted: Wed Jul 19, 2006 4:00 am
Post subject: |
|
|
The three files get generated "on the fly" by the AjaxPro handler.
If you type http://localhost/MyDemo/ajaxpro/MyDemo.WebForm1,MyDemo.ashx
into your browser an you can see the JavaScript source of the files.
90% of the times the problem is due to the namespaces.
On my website (http://josephguadagno.net/ajax.aspx) you can get a working GetServerTime sample application.
Joseph Guadagno http://josephguadagno.net
|
| Back to top |
|
 |
|
Author
|
ShandySawyer
Newbie
|
Joined: 19 Jul 2006
Posts: 23
|
|
Posted: Wed Jul 19, 2006 4:00 am
Post subject: |
|
|
Joseph,
I am trying to do the same exact thing as jceddy and I am getting the same exact error. I'm not sure what is wrong, but even your AjaxVB example will not work for me. The other thing that is somewhat troubling for me is when I try to access the URL that everyone keeps telling people to go to:
http://localhost/EmployerProfiles/ajaxpro/EmployerProfiles.TestAJAX,EmployerProfiles.ashx
it comes up with "resource not found" message from the ASP.NET compiler. What exactly is this page and why do people need to access it?
Heres my code:
-----------------------
/web.config
-----------------------
[...]
<httpHandlers>
<!-- Register the ajax handler -->
<add verb="POST,GET" path="ajax/*.ashx"
type="AjaxPro.AjaxHandlerFactory, AjaxPro" />
</httpHandlers>
[...]
-------------------------
/default.aspx
-------------------------
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="default.aspx.vb" Inherits="EmployerProfiles.TestAJAX"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhmtl1strict.dtd">
<HTML>
<HEAD>
<title>default</title>
<script language="javascript"
src="/javascript/TestAJAX.js"></script>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<button onclick="GetServerTime();"
type="button">GetServerTime</button>
</form>
</body>
</HTML>
------------------------------
/default.aspx.vb
------------------------------
Public Class TestAJAX Inherits System.Web.UI.Page
[Web Form Designer Generated Code]
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
AjaxPro.Utility.RegisterTypeForAjax(GetType(EmployerProfiles.TestAJAX))
End Sub
<AjaxPro.AjaxMethod()> _
Public Function GetServerTime() As String
Return DateTime.Now.ToString()
End Function
End Class
---------------------------------------
/javascript/TestAjax.js
---------------------------------------
function GetServerTime()
{
EmployerProfiles.TestAJAX.GetServerTime(GetServerTime_Callback)
}
function GetServerTime_Callback(response)
{
alert(response.value);
}
I tried reading the other posts that handled this issue but most of them just left me confused or didn't provide a solution. If anyone could reveal some light as to what I need to do that would be great!
Thanks!
Shandy
|
| Back to top |
|
 |
|
Author
|
JosephGuadagno
Newbie
|
Joined: 11 Jul 2006
Posts: 49
|
|
Posted: Wed Jul 19, 2006 4:00 am
Post subject: |
|
|
The page http://localhost/EmployerProfiles/ajaxpro/EmployerProfiles.TestAJAX,EmployerProfiles.ashx basically holds the JavaScript objects that will interact with the server and call the correct ASP.NET pages and methods.
Did you check to see what the response.error displays within the callback,
this might lead you to the problem.
On 7/18/06, shandy.sawyer <shandy.sawyer> wrote:
| Quote: |
Joseph,
I am trying to do the same exact thing as jceddy and I am getting the
same exact error. I'm not sure what is wrong, but even your AjaxVB
example will not work for me. The other thing that is somewhat
troubling for me is when I try to access the URL that everyone keeps
telling people to go to:
http://localhost/EmployerProfiles/ajaxpro/EmployerProfiles.TestAJAX,EmployerProfiles.ashx
it comes up with "resource not found" message from the ASP.NET
compiler. What exactly is this page and why do people need to access
it?
Heres my code:
-----------------------
/web.config
-----------------------
[...]
<httpHandlers>
<!-- Register the ajax handler -->
<add verb="POST,GET" path="ajax/*.ashx"
type="AjaxPro.AjaxHandlerFactory, AjaxPro" />
</httpHandlers>
[...]
-------------------------
/default.aspx
-------------------------
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="default.aspx.vb" Inherits="EmployerProfiles.TestAJAX"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhmtl1strict.dtd">
<HTML>
<HEAD>
<title>default</title>
<script language="javascript"
src="/javascript/TestAJAX.js"></script>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<button onclick="GetServerTime();"
type="button">GetServerTime</button>
</form>
</body>
</HTML>
------------------------------
/default.aspx.vb
------------------------------
Public Class TestAJAX
Inherits System.Web.UI.Page
[Web Form Designer Generated Code]
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
AjaxPro.Utility.RegisterTypeForAjax(GetType(EmployerProfiles.TestAJAX))
End Sub
<AjaxPro.AjaxMethod()> _
Public Function GetServerTime() As String
Return DateTime.Now.ToString()
End Function
End Class
---------------------------------------
/javascript/TestAjax.js
---------------------------------------
function GetServerTime()
{
EmployerProfiles.TestAJAX.GetServerTime(GetServerTime_Callback)
}
function GetServerTime_Callback(response)
{
alert(response.value);
}
I tried reading the other posts that handled this issue but most of
them just left me confused or didn't provide a solution. If anyone
could reveal some light as to what I need to do that would be great!
Thanks!
Shandy
>
-- |
Joseph Guadagno http://josephguadagno.net
|
| Back to top |
|
 |
|
Author
|
ShandySawyer
Newbie
|
Joined: 19 Jul 2006
Posts: 23
|
|
Posted: Wed Jul 19, 2006 4:00 am
Post subject: |
|
|
Are you asking for something like this?
function GetServerTime_Callback(response)
{
alert(response.error);
}
Unfortunately I am getting an error like so:
Line: 4 Char: 2 Error: 'Test' is undefined Code: 0 URL: http://localhost/employerprofiles/default.aspx
So its not even getting into the callback function, which won't allow me to display the response.error. Were you thinking of something else?
|
| Back to top |
|
 |
|
Author
|
JosephGuadagno
Newbie
|
Joined: 11 Jul 2006
Posts: 49
|
|
Posted: Thu Jul 20, 2006 4:00 am
Post subject: |
|
|
I would have to assume that the namespace you are using is EmployerProfiles... I did notice that the page name and class name are different and I dod not know if that will cause an issue. Try adding the namespace attribute to the GetServerTime method
<AjaxMethod(), AjaxNameSpace("EmployerProfiles")>_
Public Function GetServerTime() As DateTime
Return DateTime.Now End Function
Then in the JavaScript files change the call to
EmployerProfiles.GetServerTime(GetServerTime_Callback)
Joseph Guadagno http://josephguadagno.net
On 7/18/06, shandy.sawyer <shandy.sawyer> wrote:
| Quote: |
Are you asking for something like this?
function GetServerTime_Callback(response)
{
alert(response.error);
}
Unfortunately I am getting an error like so:
Line: 4
Char: 2
Error: 'Test' is undefined
Code: 0
URL: http://localhost/employerprofiles/default.aspx
So its not even getting into the callback function, which won't allow
me to display the response.error. Were you thinking of something else?
>
-- |
Joseph Guadagno http://josephguadagno.net
|
| Back to top |
|
 |
|
Author
|
ShandySawyer
Newbie
|
Joined: 19 Jul 2006
Posts: 23
|
|
Posted: Thu Jul 20, 2006 4:00 am
Post subject: |
|
|
Actually EmployerProfiles is the name of the project. So I did away with using that as the namespace and surrounded my class with a
"TestNamespace" Namespace and tried every possible combination but I keep getting a namespace undefined error. I then added
<AjaxNamespace("TestNamespace")> to the function, but that didn't do anything either. Currently it will tell me that "TestNamespace is undefined". I even tried renaming the page name and the class name as the same. I didn't do anything, but i'm pretty sure that it won't matter as long as the @ Page Directive points to the right class. I am getting beyond frustrated here....
Here are my new aspx.vb file and javascript file:
-------------------------------
/TestAJAX.aspx.vb
-------------------------------
Namespace TestNamespace
Public Class TestAJAX
Inherits System.Web.UI.Page
[Web Form Designer Generated Code]
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Register the page for use with the AjaxPro library. This creates the
'JavaScript files on the server for the class and methods.
AjaxPro.Utility.RegisterTypeForAjax(GetType(TestNamespace.TestAJAX))
End Sub
<AjaxPro.AjaxMethod(), AjaxPro.AjaxNamespace("TestNamespace")>
_
Public Function GetServerTime() As String
Return DateTime.Now.ToString()
End Function
End Class End Namespace
--------------------------------------
/javascript/TestAJAX.js
--------------------------------------
function GetServerTime()
{
TestNamespace.TestAJAX.GetServerTime(GetServerTime_Callback)
}
function GetServerTime_Callback(response)
{
alert(response.value);
}
|
| Back to top |
|
 |
|
Author
|
jceddy
Newbie
|
Joined: 19 Jul 2006
Posts: 20
|
|
Posted: Thu Jul 20, 2006 4:00 am
Post subject: |
|
|
Also, just so I don't get the same answer again, I tried the following changes, and still have the same error:
In WebForm1.aspx.vb:
<AjaxPro.AjaxMethod()> _
Public Function GetServerTime() As String
Return DateTime.Now.ToString()
End Function
becomes
<AjaxPro.AjaxMethod(), AjaxPro.AjaxNameSpace("AjaxVB")> _
Public Function GetServerTime() As String
Return DateTime.Now.ToString()
End Function
And in WebForm1.js:
function GetServerTime_Async()
{
// Use asynchronize call
document.getElementById("spanTime").innerHTML = 'Getting time';
// NOTE Syntax <namespace>.<classname>.method (params,
callbackfunction)
AjaxVB.WebForm1.GetServerTime(GetServerTime_Async_Callback);
}
becomes
function GetServerTime_Async()
{
// Use asynchronize call
document.getElementById("spanTime").innerHTML = 'Getting time';
// NOTE Syntax <namespace>.<classname>.method (params,
callbackfunction)
WebForm1.GetServerTime(GetServerTime_Async_Callback);
}
Thanks,
Joe
|
| Back to top |
|
 |
|
Author
|
jceddy
Newbie
|
Joined: 19 Jul 2006
Posts: 20
|
|
Posted: Thu Jul 20, 2006 4:00 am
Post subject: |
|
|
Joseph,
When I run the VB application from the directory you gave me, I ran into the same problem.
Specifically, if I hit the "GetServerTime Async" button, a "Getting time" message appears, and then the following JavaScript error is raised:
-------
Line: 12 Char: 2 Error: 'AjaxVB' is undefined Code: 0 URL: http://localhost/AjaxVB/WebFrom1.aspx
-------
If I hit the "GetServerTime Sync" button, I get the same JavaScript error, except on line 4 instead of line 12.
I noticed some posts about Security Setting Medium or something (just a vague memory from browsing through the group yesterday)...could that have something to do with it?
Thanks,
Joe
|
| Back to top |
|
 |
|
Author
|
ShandySawyer
Newbie
|
Joined: 19 Jul 2006
Posts: 23
|
|
Posted: Thu Jul 20, 2006 4:00 am
Post subject: |
|
|
jceddy,
Apparently the new version 6.7.19.1 fixes the issue of running medium trust web applications. So I downloaded the new AjaxPro.dll (version 6.7.19.1, you can get it off the website now) and added a reference to it (after deleting the old one). Unfortunately, it didn't do anything for me, so I don't think thats the problem. However I have no idea what to do because the documentation on Ajax.NET isn't very useful,
just a bunch of test cases.
Shandy
|
| Back to top |
|
 |
|
Author
|
jceddy
Newbie
|
Joined: 19 Jul 2006
Posts: 20
|
|
Posted: Thu Jul 20, 2006 4:00 am
Post subject: |
|
|
Shandy,
Yep, I also grabbed the 6.7.19.1 version and switched to the new .dll,
without it changing anything...so I don't think it's the medium trust issue.
As far as I can tell, there is supposed to be some JavaScript being dynamically generated, and it's not being dynamically generated (or maybe dynamically generated in the wrong place?), but I don't know how to test it.
Ah, well, will tinker around with it a bit more and see what I can figure out.
Cheers,
Joe
|
| Back to top |
|
 |
|
Author
|
ShandySawyer
Newbie
|
Joined: 19 Jul 2006
Posts: 23
|
|
Posted: Thu Jul 20, 2006 4:00 am
Post subject: |
|
|
Joe,
I'm pretty sure your on the right track. One thing that I have noticed is that in VS .NET it seems to treat your project name as a namespace as well (I'm using VS 2002, but its supposedly the same as 2003 but with some updates). Then when I look at the source code in the browser for the aspx, it uses the project name in front of the namespace like so:
<script type="text/javascript"
src="/ajaxpro/[projectname].[namespace].[classname],[projectname].ashx"></script>
I'm not sure if the namespace around your class is actually required.
I have been trying out both scenarios but neither seem to work. I'm also wondering is if there needs to be permissions set in IIS to allow for the .ashx files?
Shandy
|
| Back to top |
|
 |
|
Author
|
jceddy
Newbie
|
Joined: 19 Jul 2006
Posts: 20
|
|
Posted: Thu Jul 20, 2006 4:00 am
Post subject: |
|
|
Shandy,
The source code that is being generated by my project doesn't include the project name...although the project name and the namespace are the same, so maybe that's a difference.
Basically, the whole fact that the /ajaxpro/ directory contents is dynamically generated (?) confuses me...it seems strange that you can have a JavaScript include referencing a file in a directory that you can't simply access from the web browser.
For example, the following line is generated in the output of the AjaxVB project:
<script type="text/javascript"
src="/AjaxVB/ajaxpro/prototype.ashx"></script>
But "http://localhost/AjaxVB/ajaxpro/prototype.ashx" is not a page that I can access on my web server.
I have an idea that this is the root of my problems...a sneaking suspicion that I SHOULD be able to access that page in my browser, and see the JavaScript output, but I don't know where that page comes from,
or when or how it is generated.
Cheers,
Joe
|
| Back to top |
|
 |
|
Author
|
JosephGuadagno
Newbie
|
Joined: 11 Jul 2006
Posts: 49
|
|
Posted: Thu Jul 20, 2006 4:00 am
Post subject: |
|
|
Please email me the sample to jguadagno (at) gmail.com and I will look at it (or post it to this thread).
Joe
|
| Back to top |
|
 |
|
Author
|
jceddy
Newbie
|
Joined: 19 Jul 2006
Posts: 20
|
|
Posted: Thu Jul 20, 2006 4:00 am
Post subject: |
|
|
Joseph,
It's the same thing that is posted on your site at http://josephguadagno.net/ajax.aspx
The GetServerTime example with a project in it called "AjaxVB".
Do you want me to just send you the code that you have there?
|
| Back to top |
|
 |
|
Author
|
ShandySawyer
Newbie
|
Joined: 19 Jul 2006
Posts: 23
|
|
Posted: Thu Jul 20, 2006 4:00 am
Post subject: |
|
|
Well its the same as it was before, but here it is:
----------------------------
/TestAJAX.aspx
----------------------------
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="TestAJAX.aspx.vb"
Inherits="EmployerProfiles.TestNamespace.TestAJAX"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhmtl1-strict.dtd">
<HTML>
<HEAD>
<title>default</title>
<script language="javascript"
src="/employerprofiles/javascript/TestAJAX.js"></script>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<button onclick="GetServerTime();"
type="button">GetServerTime</button>
</form>
</body>
</HTML>
-------------------------------
/TestAJAX.aspx.vb
-------------------------------
Namespace TestNamespace
Public Class TestAJAX
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Register the page for use with the AjaxPro library. This creates the
'JavaScript files on the server for the class and methods.
AjaxPro.Utility.RegisterTypeForAjax(GetType(EmployerProfiles.TestNamespace.TestAJAX))
End Sub
<AjaxPro.AjaxMethod(),
AjaxPro.AjaxNamespace("EmployerProfiles")> _
Public Function GetServerTime() As String
Return DateTime.Now.ToString()
End Function
End Class End Namespace
--------------------------------------
/javascript/TestAJAX.js
--------------------------------------
function GetServerTime()
{
TestNamespace.TestAJAX.GetServerTime(GetServerTime_Callback)
}
function GetServerTime_Callback(response)
{
alert(response.value);
}
---------------------
/web.config
---------------------
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
[...database connection stuff...]
</appSettings>
<system.web>
<httpHandlers>
<!-- Register the ajax handler -->
<add verb="POST,GET" path="ajax/*.ashx"
type="AjaxPro.AjaxHandlerFactory, AjaxPro" />
</httpHandlers>
[...default settings...]
</system.web>
</configuration>
-----------------------
project settings
-----------------------
-Using VS .NET 2002
-reference made to AjaxPro in references folder
-AjaxPro.dll is version 6.7.19.1
|
| Back to top |
|
 |
|
Author
|
JosephGuadagno
Newbie
|
Joined: 11 Jul 2006
Posts: 49
|
|
Posted: Thu Jul 20, 2006 4:00 am
Post subject: |
|
|
I downloaded the code from http://josephguadagno.net/Documents/AjaxVB.zip, removed the reference to AjaxPro and replaced it with version 6.6.22.1 and it worked.
So a couple of additional questions.
Is this local? I assumed that the Virtual Directory has the folder (or the page would not show).
JavaScript is not turned off.
If you open IE and go to http://localhost/AjaxVB/ajaxpro/AjaxVB.WebForm1,AjaxVB.ashx (which should be able to be seen if you view source of the sample on my site).
Do you see the following...
if(typeof AjaxVB == "undefined") AjaxVB={};
AjaxVB.WebForm1_class = function() {};
Object.extend(AjaxVB.WebForm1_class.prototype, Object.extend(new AjaxPro.AjaxClass(), {
GetServerTime: function() {
return this.invoke("GetServerTime", {},
this.GetServerTime.getArguments().slice(0));
},
url: '/AjaxVB/ajaxpro/AjaxVB.WebForm1,AjaxVB.ashx'
}));
AjaxVB.WebForm1 = new AjaxVB.WebForm1_class();
If you notice, the JavaScript call would be AjaxVB.WebForm1.GetServerTime (<namespace>.<classname>.<method>).
Let me know.
Joseph Guadagno
|
| Back to top |
|
 |
|
Author
|
ShandySawyer
Newbie
|
Joined: 19 Jul 2006
Posts: 23
|
|
Posted: Fri Jul 21, 2006 4:00 am
Post subject: |
|
|
This project is not the localhost. Its on a webserver and is set up in the EmployerProfiles subweb. So when you refer to the root "/" your really refering to "/EmployerProfiles/". Javascript is not turned off.
I am not using the AjaxVB project but I am using a project that is set up exactly like it. The only different is the javascript functions are simpler (i'm using the ones provided on Michael Schwarz's website).
I tried accessing that page that you refer to for my own project, but asp.net tells me that the resource cannot be found. In the source code it gives me a reference like so:
<script type="text/javascript"
src="/EmployerProfiles/ajaxpro/EmployerProfiles.TestNamespace.TestAJAX,EmployerProfiles.ashx"></script>
As you can see its trying access the page like so:
src="/EmployerProfiles/ajaxpro/<projectname>.<namespace>.<classname>,<projectname>.ashx
As a result I have tried to make a JavaScript call like so:
EmployerProfiles.TestNamespace.TestAJAX.GetServerTime()
But this does not work as well. From what I can tell, it just considers the project name another namespace when I hover over the name in VS. I think I will try checking permissions for the .ashx to make sure it is not being blocked by the server. Let me know if you think of anything else.
|
| Back to top |
|
 |
|
Author
|
jceddy
Newbie
|
Joined: 19 Jul 2006
Posts: 20
|
|
Posted: Fri Jul 21, 2006 4:00 am
Post subject: |
|
|
Joseph,
Maybe there's something bogus about the way my directory structure is set up?
My root directory is c:\Inetpub\wwwroot
Within that directory, there is a "AjaxVB" directory, which contains the following files:
AjaxVB.sln AjaxVB.suo AjaxVB.vbproj AjaxVB.vbproj.webinfo AssemblyInfo.vb Global.asax Global.asax.resx Global.asax.vb Styles.css Web.config WebForm1.aspx WebForm1.aspx.resx WebForm1.aspx.vb WebForm1.js WebForm2.aspx WebForm2.aspx.resx WebForm2.aspx.vb WebForm2.js
and a subdirectory called "bin" that contains the following files:
AjaxPro.dll AjaxVB.dll AjaxVB.pdb
The AjaxPro.dll is version 6.7.19.1
Everything else is the same as the original download except that I set WebForm1.aspx as the Start Page for the Web Application.
The IIS Virtual Directory settings for the AjaxVB directory has the following options set:
The content for this resource should come from: The designated directory.
Global Read permissions are allowed Log visits is enabled Index this resource is enabled Application name: AjaxVB Starting point: <Default Web Site>\AjaxVB Execute permissions: Scripts only Application pool: DefaultAppPool
The application is running on my local machine, accessed at the following URL:
http://localhost/AjaxVB/WebForm1.aspx
If I open IE and go to http://localhost/AjaxVB/ajaxpro/AjaxVB.WebForm1,AjaxVB.ashx,
I get a "The Page Could Not Be Found" error
There isn't an "ajaxpro" directory anywhere that I could find...should there be one? Are we supposed to create it as part of the set-up for our applications?
Cheers,
Joe
|
| Back to top |
|
 |
|
Author
|
JosephGuadagno
Newbie
|
Joined: 11 Jul 2006
Posts: 49
|
|
Posted: Fri Jul 21, 2006 4:00 am
Post subject: |
|
|
Everything looks good. Inside the web.config file there should be a section for httpHandlers which registers the ashx file extension. Once ASP.NET sees a ashx file extension it routes the call to the AjaxPro library.
What does is in the page when you choose View Source within IE?
On 7/19/06, jceddy <jceddy> wrote:
| Quote: |
Joseph,
Maybe there's something bogus about the way my directory structure is
set up?
My root directory is c:\Inetpub\wwwroot
Within that directory, there is a "AjaxVB" directory, which contains
the following files:
AjaxVB.sln
AjaxVB.suo
AjaxVB.vbproj
AjaxVB.vbproj.webinfo
AssemblyInfo.vb
Global.asax
Global.asax.resx
Global.asax.vb
Styles.css
Web.config
WebForm1.aspx
WebForm1.aspx.resx
WebForm1.aspx.vb
WebForm1.js
WebForm2.aspx
WebForm2.aspx.resx
WebForm2.aspx.vb
WebForm2.js
and a subdirectory called "bin" that contains the following files:
AjaxPro.dll
AjaxVB.dll
AjaxVB.pdb
The AjaxPro.dll is version 6.7.19.1
Everything else is the same as the original download except that I set
WebForm1.aspx as the Start Page for the Web Application.
The IIS Virtual Directory settings for the AjaxVB directory has the
following options set:
The content for this resource should come from: The designated
directory.
Global Read permissions are allowed
Log visits is enabled
Index this resource is enabled
Application name: AjaxVB
Starting point: <Default Web Site>\AjaxVB
Execute permissions: Scripts only
Application pool: DefaultAppPool
The application is running on my local machine, accessed at the
following URL:
http://localhost/AjaxVB/WebForm1.aspx
If I open IE and go to
http://localhost/AjaxVB/ajaxpro/AjaxVB.WebForm1,AjaxVB.ashx,
I get a "The Page Could Not Be Found" error
There isn't an "ajaxpro" directory anywhere that I could find...should
there be one? Are we supposed to create it as part of the set-up for
our applications?
Cheers,
Joe
>
-- |
Joseph Guadagno http://josephguadagno.net
|
| Back to top |
|
 |
|