Saturday, March 24, 2012

Want to write session using AJAX technology asp.net

Dear All,

bear with me i am very new to this forum and to this technology as well.

what i want to do this is to write session using Session

this is how my code look like this

javscript file

requesturl= "productajax.aspx" this page write session for me

then this page return the xml

what i want to use that session on the other pages is this possible to use that session

please help

Thanks

your best bet is to use a web service or pagemethod for this, imo. Web service is probably better for most applications. Then you simply enable the session in each method you're going to call and you're down the road. Looks something like this:

[WebMethod(EnableSession=true)]
public string AddToSession(string something){
Session.Add("something",something);
}

[WebMethod(EnableSession=true)]
public string GetFromSession(string key){
return Session[key];
}

Obviously, you'll have more business logic in there in various places, but that's the basic way to store and retrieve froms ession using ajax. The service will by default return JSON objects, though, not xml (if you add the ScriptServiceAttribute). If you don't add the SSA, then you'll need to build your own web request and such rather than using the conveniently created proxy classes, but on the plus side you'll get your xml.


Thanks alot for you reply

i am bit confused can you please show be some examples reference if you have some that would be highly appreciated, i am student and want to complete by project.

Thanks alot dear


http://ajax.asp.net/docs/tutorials/ASPNETAJAXWebServicesTutorials.aspx

Those tutorials should get you started. The only change si that for the web method to "see" session state you have to add the parameter to it as I demonstrated before.


I found a solution to this i wrote a simple back server page for it and every thing is working like a dream thanks

No comments:

Post a Comment