Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

153
Views
En mi proyecto Asp.net Mvc 5.0, ¿cómo deshabilitar el autocompletado para Select City DropDown?

No agregué la opción de autocompletar para seleccionar automáticamente la ciudad del menú desplegable. si ejecuto la aplicación sin seleccionar la ciudad. da una alerta como "seleccionar ciudad", pero si volvemos a seleccionar ciudad, hay una ciudad que ya está seleccionada, ¿cómo es posible? he dado el código de abajo para la referencia...

Cualquier sugerencia o solución es appriciable. Gracias

 this is the ASP.NET rozar : <div class="col-md-9"> <label>City</label><span class="text text-danger">*</span> @{ if (ViewBag.cityId != null) { @Html.DropDownList("cityId", null, "--Select City--", new { @id = "ddlCity", @class = "form-control" }) } else { @Html.DropDownList("cityId", new List <SelectListItem>(), "--SelectCity--", new { @id = "ddlCity",@class = "form-control" }) } } @Html.ValidationMessageFor(model => model.cityId, "", new { @class = "text-danger" }) </div>

// mensaje de error

 if ($("#ddlcity").val() == "" || $("#ddlcity").val() == null) { alert('Please Select city') return false; }

Método MVC para obtener la lista de estados:

 public JsonResult GetStateWiseData(string stateId) { var stId = stateId.Split('_'); List < SelectListItem > pClassList = new List < SelectListItem > (); if (stId[0] == "#") { var objactvt = db.cities.Where(x => x.top == true).ToList(); objactvt.ForEach(x => { pClassList.Add(new SelectListItem { Text = x.cityName, Value = x.cityId.ToString() }); }); } else { int stid = Convert.ToInt32(stId[0]); var btn = stId[1]; List < city > objactvt; if (btn == "0") { for (int i = 0; i <= 9; i++) { objactvt = db.cities.Where(x => x.cityName.StartsWith(i.ToString()) && x.stateId == stid).ToList(); objactvt.ForEach(x => { pClassList.Add(new SelectListItem { Text = x.cityName, Value = x.cityId.ToString() }); }); } } else { objactvt = db.cities.Where(x => x.cityName.StartsWith(btn) && x.stateId == stid).ToList(); objactvt.ForEach(x => { pClassList.Add(new SelectListItem { Text = x.cityName, Value = x.cityId.ToString() }); }); } } return Json(pClassList.OrderBy(x => x.Text), JsonRequestBehavior.AllowGet); }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!