| View previous topic :: View next topic |
| Message |
|
Author
|
Pennywise
Newbie
|
Joined: 22 Jul 2006
Posts: 3
|
|
Posted: Sat Jul 22, 2006 4:00 am
Post subject: Problems folowwing the Class Example |
|
|
Hi everyone, i tried to follow the example given in http://www.ajaxpro.info/Examples/Classes/default.aspx but i found it impossible to do, here's what i have done:
----------------------------------------------------
Server side code:
public class server
{
[Ajax.AjaxMethod()]
public void StepAdd(TestClass tc)
{
Response.Write(tc.name);
}
[Ajax.AjaxMethod()]
public TestClass NewInstance()
{
return new TestClass();
}
}
[Serializable()]
public class TestClass
{
public string name = "javier";
public TestClass()
{
}
}
----------------------------------------------------
Client side code:
function Testing()
{
var TC = server.NewInstance().value;
TC.name = "nicolas";
var response = server.StepAdd(TC);
}
----------------------------------------------------
I'll explain a little what i'm tying to do:
I'm gettin an instance of the class TestClass (TC), then i change the name to "nicolas". Up to here, it's working ok, but when i try to pass the object to the ajax method "StepAdd", it just doesn't work. I tried lots of things, but i couldn't make it work.
I will appreciate any of yor help
|
| Back to top |
|
 |
|
Author
|
Pennywise
Newbie
|
Joined: 22 Jul 2006
Posts: 3
|
|
Posted: Sat Jul 22, 2006 4:00 am
Post subject: |
|
|
Thanks Joseph:
server.NewInstance().value is returning the object well, the function that isn't working is StepAdd. I just wrote Response.Write to do something, but it's not getting up to that point.
IŽll explain myself better:
while running javascript and debugging up to the poin "var response =
server.StepAdd(TC); ", it's not getting into the StepAdd Ajax function of the server side.
|
| Back to top |
|
 |
|
Author
|
JosephGuadagno
Newbie
|
Joined: 11 Jul 2006
Posts: 49
|
|
Posted: Sat Jul 22, 2006 4:00 am
Post subject: |
|
|
The value property might not be getting populated. Check the server.NewInstance().error property.
Also the Response.Write property will not work because the is no
"Response" object available. You can however set a break point within the StepAdd method.
Unless you have reason for calling Server.NewInstance() method, I would just use the JavaScript object to create the "object" and pass it to the method StepAdd.
If you want, there is also a more in depth demo on my website at http://josephguadagno.net/ajax.aspx.
Joseph Guadagno http://josephguadagno.net
|
| Back to top |
|
 |
|
Author
|
JosephGuadagno
Newbie
|
Joined: 11 Jul 2006
Posts: 49
|
|
Posted: Sun Jul 23, 2006 4:00 am
Post subject: |
|
|
Make sure that the AjaxPro library is registered in your project, and the dll is in the \bin directory,
Make sure that the following is in the Web.Config file
<httpHandlers>
<add verb="POST,GET" path="ajaxpro/*.ashx"
type="AjaxPro.AjaxHandlerFactory, AjaxPro"/>
</httpHandlers>
And the following is in the Page_Load event
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
AjaxPro.Utility.RegisterTypeForAjax(typeof(AjaxVB.WebForm1));
}
After that, view the source to see if you have 4 include statements prototype.js, core.js, classname.ashx and one other.
It should work after that.
Joseph Guadagno
|
| Back to top |
|
 |
|
Author
|
Pennywise
Newbie
|
Joined: 22 Jul 2006
Posts: 3
|
|
Posted: Tue Jul 25, 2006 4:00 am
Post subject: |
|
|
All of this is done. I used lot's of ajax methods in my project, but the onlyone that isn't working is StepAdd, and it's because i'm trying to pass an object from javascript to the server, and i followed the example of the site http://www.ajaxpro.info
|
| Back to top |
|
 |
|
Author
|
JosephGuadagno
Newbie
|
Joined: 11 Jul 2006
Posts: 49
|
|
Posted: Wed Jul 26, 2006 4:00 am
Post subject: |
|
|
Try changing the property / field name from name to firstName, there might be a conflict.
Joseph Guadagno
|
| Back to top |
|
 |
|
Author
|
JavierVallejos
Newbie
|
Joined: 27 Jul 2006
Posts: 1
|
|
Posted: Thu Jul 27, 2006 4:00 am
Post subject: |
|
|
As i said before, that was a example class, the field "name" doesn't exist in the real class, thanks.
On 7/25/06, Joseph Guadagno <jguadagno> wrote:
| Quote: |
Try changing the property / field name from name to firstName, there
might be a conflict.
Joseph Guadagno
>
|
|
| Back to top |
|
 |
|
Author
|
JosephGuadagno
Newbie
|
Joined: 11 Jul 2006
Posts: 49
|
|
Posted: Thu Jul 27, 2006 4:00 am
Post subject: |
|
|
It is hard to debug applications without seeing the actual code. First I would check with the JavaScript file to see if the object of TC is the same as the object on the server. Check all of the properties to see what type they are. Try with just string and int, then move to more complex ones.
Next, download Fiddler from the Microsoft Web site and see what is being sent and recieved from the server. There might be and error listed within the HTTP traffic that is being overlooked.
On 7/26/06, Javier Vallejos <jvallejos> wrote:
| Quote: |
As i said before, that was a example class, the field "name" doesn't
exist in the real class, thanks.
On 7/25/06, Joseph Guadagno <jguadagno> wrote:
>
> Try changing the property / field name from name to firstName, there
> might be a conflict.
>
> Joseph Guadagno
>
>
> >
>
>
-- |
Joseph Guadagno http://josephguadagno.net
|
| Back to top |
|
 |
|