AJAX.Net

G

Guest

Hi,

I have been toying around with this for a day now. Has anyone else tried it?

Two questions:
1: How do you pass a paramater to the server side event, e.g. if you wanted
to pass a selected value from a dropdownlist to the server side event? I cant
see a way of doing it. I have ended up just returning a big dataset to the
client javascript and filtering it there. I'd rather pass in a variable to
the server side code and only return the records I need.

2: I have used AJAX.Net to dynamically populate a dropdownlist without
postback based on what the user selects from another dropdownlist, works very
well, but when I do a postback afterwards the values added to the
dropdownlist are not "visible" to the server side code. This makes sense as
the changes were made on the client. How can I work around this? And does the
Client CallBack feature in ASP.Net 2.0 make this easier?

Thanks
N
 
B

Brock Allen

AJAX.NET is interesting. There are lots of ways to skin a cat. Jason Diamond
has rolled his own into a configuration-free version:

http://jason.diamond.name/weblog/2005/07/06/my-ajax-dot-net-library

But you've got to realize this is an out of band callback. The server page
lifecycle isn't geting executed here, so lots of assumptions you could make
during a normal page postback don't hold. It's simply a RPC call.
 
G

Grant Merwitz

1) To pass the selected value from a dropdownlist, use the following

DropDownList:

<select id="dd1" name="dd1"></select>

Javascript to get the selected value

document.getElementById('dd1').value

If you are using an ASp:DropDownLIst, just right click and view source to
get the correct ID from the <SELECT> html control that is created.
I know when you using a control, it changes the name to be
[TAGNAME]_[CONTROLID], or something like that.

2) If you want to call the selects value from the Code Behind you have to
declare it, and set it to runat=server. so

in html

<select runat="server" id="dd1" name="dd1"></select>

in code behind

System.Web.UI.HtmlControls.HtmlSelect dd1

You can then get its value in the CodeBehind.

Now if you are populating this dropdown from the ClientSide script, it may
very well be empty when you post back.
So just check thats not the case.

Hope this helps.
XmlHttp ROCK (or AJAX as its now coined)

Here's the article that taught me this:
http://msdn.microsoft.com/asp.net/d...rary/en-us/dnaspp/html/lifewithoutrefresh.asp

Don't know about .NET 2.0, trying to play with that myself currently
 
C

clintonG

I've read the 2.0 CallBack is a lightweight compared to what is being
released by those building the libraries. That jives with Microsoft's
typical Notepad Edition release policies to put some 'thing' out and improve
it over time. The Catch-22 is waiting or adopting what others develop n.o.w.
and perhaps having to rebuild if and when Microsoft finally release an
elegant and powerful solution to warrant doing so.

The 2.0 Membership and Roles come to mind in this context as do Master Pages
and Themes.

<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,072
Latest member
trafficcone

Latest Threads

Top