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

populate the Dropdown list by client side using javascript

Hi this is venkat,
i have a drop downlist for country, i composed a code in javascript for that and its working in HTML page but i dont know how to call the same javascript function in asp.net(C#) dropdownlist. please advice me and send me code for how to call the function..
Mar 19 '08 #1
4 2937
Be specific in the question.

You can call the javascript method on any event which you can do by writing it either in the aspx page or in the code with (control.attributes.add("[Event]","[javascript code or function call]"))
Mar 19 '08 #2
Frinavale
9,735 Expert Mod 8TB
Hi this is venkat,
i have a drop downlist for country, i composed a code in javascript for that and its working in HTML page but i dont know how to call the same javascript function in asp.net(C#) dropdownlist. please advice me and send me code for how to call the function..
Hi Venkat :)

JavaScript works in the browser (client side).
Your C# code works on the web server (server side).
You cannot call JavaScript functions from your C# code.

What you can do is set each of your DropDownList Items to have an "onclick" event:

Expand|Select|Wrap|Line Numbers
  1. foreach(ListItem i in MyCountryDropDownList.Items)
  2. {    i.Attributes.Add("onclick","theJavaScriptFunction();");}
  3.  
This will cause the JavaScript function to be called when ever the DropDownList item has be clicked on.

If you need your C# code to generate your country list on the server, then you must implement this in C#. You cannot call your JavaScript function from the server.
-Frinny
Mar 19 '08 #3
Hi Thanks for quick reply
i need like below link- just click this url and see there is country option- http://www.24x7a2z.com/iff/ver2/feedback.html. after selecting the corresponding country, then i will store that selected country to DB? will it possible to do that? please let me know how it possible?...
Mar 20 '08 #4
Frinavale
9,735 Expert Mod 8TB
Hi Thanks for quick reply
i need like below link- just click this url and see there is country option- http://www.24x7a2z.com/iff/ver2/feedback.html. after selecting the corresponding country, then i will store that selected country to DB? will it possible to do that? please let me know how it possible?...
You could create a database with a table for your countries...then you can populate your DropDownList with countries retrieved from the database.

Normally when you have a form like that you are saving the person's information in some way. Saving it into a database is a good idea.

-Frinny
Mar 20 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: ziggs | last post by:
I have an asp form that has a text box called "colorBox". Just before text box is the word "Color" that is hyperlinked and will run the color.asp if pressed to show all of the colors in a...
1
by: Rod Early | last post by:
I need to know when the select element's dropdown list is opened (as when the user clicks on the arrow or does ALT-downarrow from the keyboard). Similarly, I need to known when the dropdown list...
32
by: Continental Translations | last post by:
Can anybody help me? I am trying to create two drop down menus, where the results of the second one vary depending on what was selected in the first one. I am using MS Script Editor in MS Front...
6
by: Paul | last post by:
I am trying to setup a field validator and tried using the control to validate set to a dropdown list box but did not seem to work. Is there anyway to set this up or do you need to use client side...
6
by: Mark | last post by:
I have two dropdown lists. Both have autopostback set to true. In both dropdowns, when you select an item from the list, it redirects to the Value property of the dropdown. Nothing fancy. ...
9
by: Chris | last post by:
I pop up a Modal form on a web page that allows the user to update the selections of a dropdownlist via adding a new item to the db (Sql Server).The only thing is this list is on the page beneath...
1
by: Ed Chiu | last post by:
Hi, I have 2 dropdown lists on an ASP.Net page, the first is a list of states of US, the second is City list. When user selects a state, the web page does a postback, create a DB connection and...
5
by: John A Grandy | last post by:
is it possible to write a vb.net code (intended to run on the client-side) that would invoke an instance of IE, have it download a page from a certain URL, and then pre-populate some of the...
2
by: Nick | last post by:
What I want to do is have 2 pull down lists, for example a state pull down list and a city pull down list. What I would like to have done is when you select a state from the state pull down list...
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...
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
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.