-
Javascript and ASP.Net....Perfect Together???
I have a piece of javascript that take items from one listbox to another.
Everything works fine, HOWEVER, any postback logic that fires does NOT see
the newly added items.
The interesting thing is that all of the changes I made in the textboxes
ARE visible.
It seems to be the fact that I am adding these items using javascript outside
of knowledge of ASP.
Is there a way to FORCE ASP to "see" the newly added items?
Thanks in advance.
-
Re: Javascript and ASP.Net....Perfect Together???
Crack Head,
The state of the listbox, as ASP.NET knows it, is in the veiwstate hidden
field on the form. When you add an entry in the listbox through client side
scripting the state in the viewstate hidden field for the listbox is not
changed. The next time the form is submitted to the server, the server reconstructs
the listbox contents from the viewstate field. This is why your addition
is not there.
In this situation you could do one of two things:
1) Do a postback to the server when adding the entry to the listbox. This
is the intended webform model. The postback is more efficient than most
think, but I'd only recommend it for intranet apps, or if your audience is
not dial-up.
2) Retrieve the values added by the client scripting by using the Request
object. It's still there and works mostly the same as it did in previous
versions. You could then add it to the listbox control on the server if
needed.
I think the postback route was MS's intention as the easiest route to take,
but the reality is that it's not the most efficient way for Internet apps
to accomplish that set of functionality.
Ian Drake
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks