FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister  MasterVB.NET
Visual Basic 2005 .NET Forum
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Problems folowwing the Class Example
 
Post new topic   Reply to topic    MasterVB.NET Forum Index -> ASP.NET General Discussion
View previous topic :: View next topic  
Message
Author
Pennywise
Newbie
Joined: 22 Jul 2006
Posts: 3

PostPosted: Sat Jul 22, 2006 4:00 am    
Post subject: Problems folowwing the Class Example
Reply with quote

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
View user's profile Send private message
Author
Pennywise
Newbie
Joined: 22 Jul 2006
Posts: 3

PostPosted: Sat Jul 22, 2006 4:00 am    
Post subject:
Reply with quote

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
View user's profile Send private message
Author
JosephGuadagno
Newbie
Joined: 11 Jul 2006
Posts: 49

PostPosted: Sat Jul 22, 2006 4:00 am    
Post subject:
Reply with quote

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
View user's profile Send private message
Author
JosephGuadagno
Newbie
Joined: 11 Jul 2006
Posts: 49

PostPosted: Sun Jul 23, 2006 4:00 am    
Post subject:
Reply with quote

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
View user's profile Send private message
Author
Pennywise
Newbie
Joined: 22 Jul 2006
Posts: 3

PostPosted: Tue Jul 25, 2006 4:00 am    
Post subject:
Reply with quote

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
View user's profile Send private message
Author
JosephGuadagno
Newbie
Joined: 11 Jul 2006
Posts: 49

PostPosted: Wed Jul 26, 2006 4:00 am    
Post subject:
Reply with quote

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

Joseph Guadagno



 

Back to top
View user's profile Send private message
Author
JavierVallejos
Newbie
Joined: 27 Jul 2006
Posts: 1

PostPosted: Thu Jul 27, 2006 4:00 am    
Post subject:
Reply with 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:
Quote:

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

Joseph Guadagno


>




 

Back to top
View user's profile Send private message
Author
JosephGuadagno
Newbie
Joined: 11 Jul 2006
Posts: 49

PostPosted: Thu Jul 27, 2006 4:00 am    
Post subject:
Reply with quote
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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    MasterVB.NET Forum Index -> ASP.NET General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Archieve

Powered by phpBB © 2001, 2002 phpBB Group, used in Visual Basic 2005 .NET Forum

| Visual Basic .NET Forum | Online Recipe Archiver | Shareware Freeware PAD | Lowongan Kerja | Kamus Online | Health Supply | Digital Camera Review |
Orang Paling Keren

RSS