Visual Basic .NET » ASP.NET General Discussion
Problems folowwing the Class Example -- Pennywise --


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
{

public void StepAdd(TestClass tc)
{
Response.Write(tc.name);
}


public TestClass NewInstance()
{
return new TestClass();
}
}


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

-- Pennywise --


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.

-- JosephGuadagno --


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 


-- JosephGuadagno --


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

-- Pennywise --


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 


-- JosephGuadagno --


Try changing the property / field name from name to firstName, there might be a conflict.

Joseph Guadagno

-- JavierVallejos --


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
>

 

-- JosephGuadagno --

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:


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 


[Submit Comment]Home