473,394 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

List Box Populated Client Side

I have a list box which gets populated client side (Javascript).

Now when I submit the page - I need to capture all the list item and
store it in database.

What is the elegant way to do it in asp.net?

Thanks
KM

Dec 26 '05 #1
4 4079
On Mon, 26 Dec 2005 09:55:56 -0800, math.kiran wrote:
I have a list box which gets populated client side (Javascript).

Now when I submit the page - I need to capture all the list item and
store it in database.

What is the elegant way to do it in asp.net?

Thanks
KM

Use XML to encode the option array
corresponding to the select in a hidden type field. To this effect
you either enumerate the option array, or give all the options the same id
(as in <option id=myoption value=1>one</option>) and enumerate
document.all.myoption.
You should build xml like:
<myoption value=1>
<myoption value=2>
....

Once you receive the object representing the options you can store this in
the database via a stored procedure that accepts the XML as a parameter,
loads the XML into a temporary dom and processes this dom via a select.
Dec 26 '05 #2
Are you saying to create a client side XML data island.

Yes that is a way to go -- but don't you think it might be a problem
with browsers like firefox etc.

Thanks

Dec 26 '05 #3
On Mon, 26 Dec 2005 11:22:53 -0800, JaduBlue wrote:
Are you saying to create a client side XML data island.

Yes that is a way to go -- but don't you think it might be a problem
with browsers like firefox etc.

Thanks

A data island is one possibility. However, what I suggest is just a hidden
variable that contains the XML for a collection of <option>s
I hope this is clear.

Dec 27 '05 #4
Hi,
There is an indirect way to get all the list items at the server side
which are added from the client side javascript.
We can retrieve all the list items(only the selected list item values)
using
Request.Form("lstCountries")

So before posting back to the server, make all the list items selected
= true.
using the script code function call
like

function selAll(){
var lst = document.getElementById("lst1");
var j=0;
for(j=lst.length-1;j>=0;j--){
lst.options[j].selected=true;
}
}

THen at the server side, just retrieve using Request.Form("lst1");

Bye,
Praveen P.

Dec 27 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Christer Alkerud | last post by:
Hi I hope anyone can give me a hint how to continue I have an ASP page containing 3 list boxes. When the page is opened the list boxes are populated with some default values from a...
5
by: Allan M. | last post by:
I have a series of select boxes that must be populated client side, because they interact with each other. The design specification calls for these boxes to be updated without having to make a...
8
by: Galina | last post by:
Hello I have 6 dependent list boxes on my ASP page:  Faculty;  Lecturer;  Course;  Course occurrence;  Group;  Week commencing date. When faculty is selected, lists of lecturers and...
4
by: Jeremy S | last post by:
When users select from a DropDownList, I'd like to have the selected value get copied to a TextBox also on the same page. 1. How do I wire up a client-side JavaScript function call to a...
2
by: jeffmagill | last post by:
Hello everyone, I have what I thought was a simple script but I cant figure it out. Anyway, I want to set the selected item of a drop down list with information i am recieving from...
11
by: eureka | last post by:
Hi All, I'm training in Servlets, JSP and JavaScript, I have a web page in which there's a "StudentName" textbox and below it is a "Names" Dropdown list. Initially the Textbox is empty and...
5
by: David Longnecker | last post by:
I'm working to create a base framework for our organization for web and client-side applications. The framework interfaces with several of our systems and provides the business and data layer...
1
by: DanWeaver | last post by:
I have several lists each of several hundred selectable items. I send all lists to the client along with the javascript. When the user types the first letter of the item in a text box, I know which...
7
controlbox
by: controlbox | last post by:
I have recently inplemented some drop-down lists (combos) on a page where one is dynamically populated according to the selection of another using the microsoft ajax extensions. I had to set...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.