drop-down-menu interview questions
Top drop-down-menu frequently asked interview questions
Why is the dropdown not showing my blank item first? Here is what I have
drpList.Items.Add(New ListItem("", ""))
With drpList
.DataSource = myController.GetList(userid)
.DataTextField = "Name"
.DataValueField = "ID"
.DataBind()
End With
Edit ~ I am binding to a Generig List, could this be the culprit?
Source: (StackOverflow)
Can anyone recommend a dropdownlist control for asp.net (3.5) that can render option groups? Thanks
Source: (StackOverflow)
How to make a dropdown
in yii2
using an activeform
and a model? Since all the methods has changed in yii2
,how it is done in the new one?
Source: (StackOverflow)
I want to set selecteditem for asp. net dropdownlist control programmatically.
So I want to pass a value to the dropdownlist control to set the selected item where is the item equal to the passed value.
Source: (StackOverflow)
I have a div (let's say the id is "container") with many elements in it, including a select element. I'd like to select all everything in the div except the select.
Things I've tried:
$("#container *:not(select)")
$("#container *:not(#selectorid)")
//put a div around the select and...
$("#container *:not(#selectorcontainer)")
$("#container *:not(#selectorcontainer *)")
$("#container *:not(#selectorcontainer, #selectorcontainer *)")
Also tried without wildcard descendant selector, so just like all the above, but
$("#container:not(#selectorid)")
Source: (StackOverflow)
In IE, the dropdown-list takes the same width as the dropbox (I hope I am making sense) whereas in Firefox the dropdown-list's width varies according to the content.
This basically means that I have to make sure that the dropbox is wide enough to display the longest selection possible. This makes my page look very ugly :(
Is there any workaround for this problem?
How can I use CSS to set different widths for dropbox and the dropdownlist?
Source: (StackOverflow)
If you change a dropdown and refresh the page, Firefox seems to ignore the selected attribute.
<option selected="selected" value="Test">Test</option>
It will in fact select the option you had previously selected (before the refresh). This ends up being a problem for me since there is an event triggered on the dropdown which changes other things. Is there a way to make firefox stop this behavior (other than firing another event when the page loads)?
Source: (StackOverflow)
All right, say I have this:
<select id='list'>
<option value='1'>Option A</option>
<option value='2'>Option B</option>
<option value='3'>Option C</option>
</select>
What would the selector look like if I wanted to get "Option B" when I have the value '2'?
Please note that this is not asking how to get the selected text value, but just any one of them, whether selected or not, depending on the value attribute. I tried:
$("#list[value='2']").text();
But it is not working.
Source: (StackOverflow)
I'm using bootstrap for the first time and really liking it - but one thing I'd like to do is have my menu automatically drop down on hover over, rather than having to click the menu title. I'd also like to lose the little arrows next to the menu titles.
Source: (StackOverflow)
I was wondering if it's possible to get jQuery to select an option, say the 4th item, in a dropdown box?
<select>
<option></option>
<option></option>
<option></option>
<option></option>
<option></option>
</select>
I want the user to click a link, then have the select box change it's value, as if the user has selected it by clicking on the option.
Source: (StackOverflow)
This seems to be a frequent issue around the web, although none of the answers seem to have helped.
I have a DropDownList object in my web page. When I click on it and select a different value, nothing happens, even though I have a function wired up to the SelectedIndexChanged
event. I'll try and post my code here as orderly as possible:
First, the actual object's HTML code:
<asp:DropDownList ID="logList" runat="server"
onselectedindexchanged="itemSelected">
</asp:DropDownList>
And this is that function, itemSelected
:
protected void itemSelected(object sender, EventArgs e)
{
Response.Write("Getting clicked; " + sender.GetType().ToString());
FileInfo selectedfile;
Response.Write("<script>alert('Hello')</script>");
foreach (FileInfo file in logs)
{
if (file.Name == logList.Items[logList.SelectedIndex].Text)
{
Response.Write("<script>alert('Hello')</script>");
}
}
}
None of the Responses appear, and that portion of JavaScript is never run. I've tried this on the latest 3.6 version of Firefox, as well as Internet Explorer 8. This is being served from a Windows Server 2003 R2 machine, running ASP.Net with the .NET Framework version 4.
If anyone can help, that would be great.
Source: (StackOverflow)
I want to set DataTextField
and DataValueField
of a Dropdownlist
(languageList) using a Dictionary (list) of languageCod
(en-gb) as key and language name (english) as the text to display.
Relevant Code:
string[] languageCodsList= service.LanguagesAvailable();
Dictionary<string, string> list =
new Dictionary<string, string>(languageCodsList.Length);
foreach (string cod in languageCodsList)
{
CultureInfo cul = new CultureInfo(cod);
list.Add(cod, cul.DisplayName);
}
languageList.DataSource = list;
languageList.DataBind();
How can I set DataTextField
and DataValueField
?
Source: (StackOverflow)
How implement subj?
when i write:
<form>
<select>
<option value="0">aaaa</option>
<option value="1">bbbb</option>
</select>
</form>
then default selected item is "aaaa"
when i write:
<form>
<select>
<option value=""></option>
<option value="0">aaaa</option>
<option value="1">bbbb</option>
</select>
</form>
then default selected item is blank, but this blank item presents in drop down.
how i can implement SELECT tag with default blank value that hidden in dropdown list?
Source: (StackOverflow)