By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,517 Members | 871 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,517 IT Pros & Developers. It's quick & easy.

ASP .NET and Javascript

P: n/a
Hi,

I have an ASP .NET page with codebehind in a vb file.
The page has a dropdown control, and a JS function which used HTTP XML
Request to get the data from the database, and populate the dropdown.
Actually, the JS creates the OPTION elements using th retrieved db
data, and adds them to the SELECT element using DOM objects.

The dropdown works ok, and the items are visible, but when the user
clicks "Save" button, and the page posts back to the server, in the VB
codebehind, the selected value in the dropdown is empty, and the items
collection is empty.

Why is this? How can I fix this behavior?

Thanks in advance,

Richard
Jun 27 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Apr 15, 5:38 pm, Rick <e_man_onl...@hotmail.comwrote:
Hi,

I have an ASP .NET page with codebehind in a vb file.
The page has a dropdown control, and a JS function which used HTTP XML
Request to get the data from the database, and populate the dropdown.
Actually, the JS creates the OPTION elements using th retrieved db
data, and adds them to the SELECT element using DOM objects.

The dropdown works ok, and the items are visible, but when the user
clicks "Save" button, and the page posts back to the server, in the VB
codebehind, the selected value in the dropdown is empty, and the items
collection is empty.

Why is this? How can I fix this behavior?

Thanks in advance,

Richard
Hard to tell w/o any actual javascript samples to go by. :)

I'll take a shot at it though.

<html>
<head>
<script>
function set_option_item(sendValue,displayValue) {
var elem = document.createElement('option');
elem.setAttribute('value',sendValue);
elem.innerHTML = displayValue;
return elem;
}
function load_option_elements () {
var sel = document.getElementById('dropdown');
for (i=1; i<10; ++i)
sel.appendChild(set_option_item('00'+i,'Item #'+i));
}
</script>
</head>
<body onload="load_option_elements();">
<form method=post action="http://10.50.10.109/cgi-bin/envpost.cgi">
<select name="dropdown" id="dropdown">
</select>
<input type="submit" value="Save" />
</form>
</body>
</html>

This displays 9 items labeled "Item #1" to "Item #9" within the drop-
down select box. A three-digit numeric is successfully posted to the
server using the above code.

Can't help ya with server-side VB here (this is a javascript thread).

Post some code that you're using to test (make is as simple as
possible) to get some others willing to assist.

-Tom Woz
Jun 27 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.