473,241 Members | 1,467 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,241 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 2931
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
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.