473,396 Members | 1,775 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,396 software developers and data experts.

.NET (asp:Dropdownlist, javascript)

I have problem with asp:Dropdownlist. I have a dropdownlist control in Page1.aspx and I want to assign value and Text to dropdown list form Page2.aspx from java script function. I am able to assign values to asp:textbox but not asp:dropdownlist

code is as follow when i call this function BindShipper();

function BindShipper(SearchResultFor, vendorID, localID,companyName, companyAdd1, companyAdd2, companyCity, companyState, companyZip, companyCountry, companyContact, companyComment, companyPhone, companyFax, companyEmail)
{
window.opener.document.Form1.txtShipperComment.val ue = companyComment;
window.opener.document.Form1.txtShipperCompanyName .value = companyName;
window.opener.document.Form1.txtShipperAddress1.va lue = companyAdd1;
window.opener.document.Form1.txtShipperAddress2.va lue = companyAdd2;
window.opener.document.Form1.txtShipperCity.value = companyCity;
//window.opener.document.Form1.ddlShipperState.Items .Add(companyState);
window.opener.document.Form1.txtShipperZip.value = companyZip;
//window.opener.document.Form1.ddlShipperCountry.Ite ms.Insert(0,companyCountry); // where "0" is the value for this selection

//ListItem litShipperState = new ListItem("--Select--","");
//ddlState.Items.Insert(0,litShipperState);
//ddlState.Items[0].Selected = true;
}
--------------------------------
From: Urmal Patel

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>yfHa3eXbzEOtaHi+/omsrg==</Id>
Nov 18 '05 #1
1 2260
"Urmal Patel via .NET 247" <an*******@dotnet247.com> wrote in message
news:ef**************@TK2MSFTNGP09.phx.gbl...
I have problem with asp:Dropdownlist. I have a dropdownlist control in Page1.aspx and I want to assign value and Text to dropdown list form
Page2.aspx from java script function. I am able to assign values to
asp:textbox but not asp:dropdownlist
code is as follow when i call this function BindShipper();

function BindShipper(SearchResultFor, vendorID, localID,companyName, companyAdd1, companyAdd2, companyCity, companyState, companyZip,
companyCountry, companyContact, companyComment, companyPhone, companyFax,
companyEmail) {
window.opener.document.Form1.txtShipperComment.val ue = companyComment;
window.opener.document.Form1.txtShipperCompanyName .value = companyName;
window.opener.document.Form1.txtShipperAddress1.va lue = companyAdd1;
window.opener.document.Form1.txtShipperAddress2.va lue = companyAdd2;
window.opener.document.Form1.txtShipperCity.value = companyCity;
//window.opener.document.Form1.ddlShipperState.Items .Add(companyState);
window.opener.document.Form1.txtShipperZip.value = companyZip;
//window.opener.document.Form1.ddlShipperCountry.Ite ms.Insert(0,companyCount
ry); // where "0" is the value for this selection
//ListItem litShipperState = new ListItem("--Select--","");
//ddlState.Items.Insert(0,litShipperState);
//ddlState.Items[0].Selected = true;
}


Do you want to add an element to a dropdown list using client side java
script?
Your code seems to have mixed up clientside and server side programming.
I think what you want to do (client side) is something like:

var newOptionElement = document.createElement("<option value='" + yourValue
+ "'>" + yourtext + "</option>";
window.opener.document.Form1.ddlShipperState.add(n ewOptionElement);

http://msdn.microsoft.com/workshop/b...ateelement.asp
http://msdn.microsoft.com/library/de...lement/add.asp
cheers,
mortb

Nov 18 '05 #2

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

Similar topics

1
by: Marius | last post by:
Hi all, I need an asp:dropdownlist on a webform that is databound to a dataset. This works fine and returns the data to populate my dropdownlist. In the DB I only have valid data, but I need a...
1
by: Thierry | last post by:
Hi, Is it possible to get the value of an asp:dropdownlist in javascript. I need to get that value to assign it to a hyperlink. This does not work:...
7
by: Lastie | last post by:
Hi all, I’ve got a ‘dropdownlist’ web control and I can add ‘listitem’ no problem. I can also bind data from an SQL database fine. My problem is that I want to do both at the same...
1
by: Xuanly ly via .NET 247 | last post by:
asp:dropdownlist always display infront of everything and I can't make it display behind HELP HELP help!!!. <form id="Form1" method="post" runat="server"> <asp:TextBox id="TextBox1"...
1
by: Miguel Dias Moura | last post by:
Hello, I have two questions concerning Asp:DropDownList 1. How to fill a DropDownList from runtime and set its default item? 2. How do use a DropDownList in each datagrid record? All...
2
by: John Smith | last post by:
I have this DataGrid: <asp:datagrid id="dg1" runat="server" AutoGenerateColumns="False"> <Columns> <asp:TemplateColumn HeaderText="SM"> <ItemTemplate> <asp:Label id="Label2" runat="server"...
3
by: =?Utf-8?B?T2xkQnV0U3RpbGxMZWFybmluZw==?= | last post by:
If I want to hang javascript off of an asp:DropDownList control, how would I do this? There does not seem to be a "onchange" event so do I have to use an HTML control to do this?
0
by: Britain Crooker | last post by:
First - my MSDN Posting Alias isn't defined yet because the MSDN site is having problems, it came back with " We were unable to communicate with the Managed Newsgroups registration system". I...
6
by: uicouic | last post by:
Hi all. I need help about this particular aspect. In a webform I have an <asp:textbox> (txtName) and <asp:DropDownList> (lstSchool) with 2 values inside. I have typed in a value for the...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.