jQuery: HTML DropDown list works, but ASP Control DropDown list does not
Tag : jquery , By : user119605
Date : March 29 2020, 07:55 AM
This might help you This is probably because the ID of the asp control is a server side id whereas the id of a normal control is client side and they do not always match especially if they are nested or in master pages. To make this work you could modify your script, if your script is in the page, on the server side something like this: $("#<%=SelectAccount.ClientID %>").change(function () { ... }
|
Dropdown list implementation
Date : March 29 2020, 07:55 AM
this will help This makes it look really like a dropdownlist. Here is a code I used for creating one.For this first import the framework,make the dynamic view and add the background image.and after add the table in the dynamic view. -(IBAction)DropDownTable:(id)sender
{
UIView *BackGrView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 200)];
BackGrView.hidden = NO;
if(TableView.frame.origin.y ==203)
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5f];
[TableView setFrame:CGRectMake(224, 204, 27, 160)];
[UIView commitAnimations];
[self.view TableView];
}
else if (TableView.frame.origin.y == 204)
{
[TableView setFrame:CGRectMake(224, 203, 27, 0)];
BackGrView.hidden = YES;
}
[self.view addSubview:TableActivityLevel];
}
|
Date : March 29 2020, 07:55 AM
hope this fix your issue I have created a search input for my website that is attached to a dropdown menu. But I need to populate the items in the dropdown menu with items from a html helper select list which is essential for the search function. Is it possible to render the items of the search list in a bootstrap dropdown menu that is posted to a controller? , Use the conventional hyperlink tags in the bootstrap dropdown-menu: <ul class="dropdown-menu">
@foreach (var searchType in new[] { "User", "Restaurant", "Cuisine" })
{
<li><a href="#">@searchType</a></li>
}
</ul>
<input type="hidden" name="SearchBy" />
<script>
$(".dropdown-menu a").click(function() {
$("input[name='SearchBy']").val($(this).html());
});
</script>
|
Html Helper Dropdown List doesn't render the list of items in the dropdown
Tag : chash , By : scott.sizemore
Date : March 29 2020, 07:55 AM
To fix this issue I'm trying to create a dropdown list in MVC with the Html Helper (Html.DropdownList) using the following code, but the list is not getting rendered on the UI. I have tried to bind the DropDownList with an IEnumerable collection of SelectListItems but not getting the exact result. Can someone point out the missing link. Here is the fiddler https://dotnetfiddle.net/26h7xa for the code and below is the code: , Add one property in your model like as, public List<SelectListItem> lstEmployee {get; set;}
public ActionResult Index()
{
Employee model = new model();
IEnumerable<Employee> empList = EmployeeData();
model.lstEmployee = from e in empList select new SelectListItem { Selected = true, Text = Convert.ToString(e.Id), Value = String.Concat(e.FirstName, " ", e.LastName) };
return View(model);
}
@model Employee // Whatever your model path
@Html.DropDownList("ddlEmployee", model.lstEmployee)
|
Filling a dropdown list based on another dropdown list in the same html form
Date : March 29 2020, 07:55 AM
this will help You can achieve this using an object to hold the values and their associated dropdown's descriptions. In order to do this, you firstly need to add an event listener to your dropdown so that it will detect a change when you pick a new fruit. Using the change event listener, you can retrieve the value of the option which was selected using this.value. Using the value from the option selected, you can proceed to get its associated dropdown's values from the object called prices (this will return an array). Once you've gotten this array, you can loop through it and "build" a string of HTML using .reduce() to place as the options for the price select tag. Once you've built this string, you can append it inside the select tag using .innerHTML which "converts" your HTML string to DOM objects (real elements rather than just text): const prices = {"apple":[{value:3,desc:"Apple 1kg 3€"},{value:5,desc:"Apple 2kg 5€"},{value:7,desc:"Apple 3kg 7€"}],
"banana":[{value:3,desc:"Banana 2kg 3.5€"},{value:5,desc:"Banana 4kg 7€"},{value:7,desc:"Banana 5kg 11€"}],
"peach":[{value:3,desc:"Peach 1.5kg 3€"},{value:5,desc:"Peach 3kg 6€"},{value:7,desc:"Peach 4kg 7€"}]}
const price = document.querySelector('[name=price]');
document.querySelector('[name=fruit]').addEventListener('change', function(e) {
price.innerHTML = prices[this.value].reduce((acc, elem) => `${acc}<option value="${elem.value}">${elem.desc}</option>`, "");
});
<select name="fruit">
<option value="apple">Apple</option>
<option value="banana">Banana</option>
<option value="peach">Peach</option>
</select>
<br />
<select name="price">
<option value="3">Apple 1kg 3€</option>
<option value="5">Apple 2kg 5€</option>
<option value="7">Apple 3kg 7€</option>
</select>
...
let options = "";
for(obj of prices[this.value]) {
options += '<option value="' +obj.value +'">' +obj.desc +'</option>';
}
price.innerHTML = options;
...
|