469,942 Members | 2,499 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,942 developers. It's quick & easy.

Pass data from the JavaScript Object to the ASP.NET Ajax Enabled Server Control code

Frinavale
9,735 Expert Mod 8TB
I've created a few ASP.NET Ajax Enable Server controls.

There are 2 components to these controls: a server side Object that deals with the server side stuffs, and a client side Object that deals with the client side stuff.

My controls are pretty nifty and quite useful but I keep coming back come back to the same question:

How do I pass data from the JavaScript Object to the Server code?

Up 'til now I've been using HiddenFields in order to accomplish my needs but I find this cumbersome, bulky, rather nasty looking and feeling...there has to be a better way!

ASP.NET is smart enough to take the data from the server code and pass it into the JavaScript Object when it is loaded in the browser.

Why can't it take the data from the client code (the JavaScript Object) and pass it into the Server Object when it is loaded on the server?

Does anyone know how to do this?

Or even have an idea of what I should be googling for because everything I find on these controls doesn't cover how to pass information from the JavaScript Object to the Server Object (they're usually very basic, simple articles/tutorials and I'm starting to wonder if anyone's even attempted to do this)

I'm starting to look into JSON but I have no idea how I'm going to send the JSON Object to the server...or how to retrieve and this Object once it gets there...

Thanks,

-Frinny
May 27 '09 #1
3 5217
Dormilich
8,652 Expert Mod 8TB
How do I pass data from the JavaScript Object to the Server code?
the magic word is "serialization". (I know of JSON and WDDX, but there may be more)

Why can't it take the data from the client code (the JavaScript Object) and pass it into the Server Object when it is loaded on the server?
my guess is that this was not intended from the beginning. (despite that you need a new request for that)

I'm starting to look into JSON but I have no idea how I'm going to send the JSON Object to the server...or how to retrieve and this Object once it gets there...
the crucial point is that you need a new http request for that (be it AJAX or a (re)load). which way to go probably depends on what that JS object is supposed to do in ASP.NET
May 27 '09 #2
Hi,
I guess you found a solution already but for those of you who still having problems sending data from the client to the server: you can use ASP.NET Ajax and pass a JavaScript object to the server

Check this post: http://ajaxme.blogspot.com/2010/10/p...to-server.html

Eran Hefer.
Oct 25 '10 #3
Frinavale
9,735 Expert Mod 8TB
It's been a while since I've worked with any Server controls, and even though your post isn't related to server controls, it was insightful (a good refresher). It may have helped your blog if you explained what PageMethods is.

The Extreme ASP.NET:Client-Side Web Service Calls with AJAX Extensions article explains the topic quite thoroughly.

I am not prepared to expose any web methods in the project that I was working with...but this is a good idea for future projects. So long as the proper security is implemented around the web-methods to prevent unwanted execution from occurring.

-Frinny
Oct 25 '10 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

By using this site, you agree to our Privacy Policy and Terms of Use.