Click here to Skip to main content
14,326,246 members
   

ASP.NET

 
QuestionQuery timing out, help please!!! Pin
samflex19-Jul-19 8:38
membersamflex19-Jul-19 8:38 
AnswerRe: Query timing out, help please!!! Pin
ZurdoDev19-Jul-19 10:14
professionalZurdoDev19-Jul-19 10:14 
AnswerRe: Query timing out, help please!!! Pin
David Mujica22-Jul-19 7:59
memberDavid Mujica22-Jul-19 7:59 
QuestionForm Designer Pin
wrightyrx715-Jul-19 4:58
memberwrightyrx715-Jul-19 4:58 
AnswerRe: Form Designer Pin
Mycroft Holmes15-Jul-19 11:26
memberMycroft Holmes15-Jul-19 11:26 
GeneralRe: Form Designer Pin
wrightyrx715-Jul-19 11:33
memberwrightyrx715-Jul-19 11:33 
GeneralRe: Form Designer Pin
Mycroft Holmes15-Jul-19 14:08
memberMycroft Holmes15-Jul-19 14:08 
QuestionGetting undefined in Cascading DropDownList In ASP.Core MVC ? Pin
Abdalla Ben Omran11-Jul-19 9:29
memberAbdalla Ben Omran11-Jul-19 9:29 
In the first DropdownList should display the Countries and in the second should display Cities based on the Country like .. USA then display just cities in USA . well i am getting undefined in dropdown city the Question is why i am getting always undefined in City dropDown list ?

here is countrol :
<pre> public ActionResult Index()
        {
            Details();
            return View();
        }

        public void Details (
        {
            var model = db.GetUniversities().ToList();
            List<SelectListItem> li = new List<SelectListItem>();
            li.Add(new SelectListItem { Text = "Please select Country",Value="0"});
            foreach (var item in model)
            {
                li.Add(new SelectListItem { Text = item.Country, Value = item.Id.ToString()});
                ViewBag.state = li;
            }
        }
        [HttpPost]
        public JsonResult GetCity (int id)
        {
            var ddlCity = db.GetUniversities().Where(x => x.Id == id).ToList();
            List<SelectListItem> licities = new List<SelectListItem>();

            //licities.Add(new SelectListItem { Text = "--Select City--", Value = "0" });

            if (ddlCity != null)
            {
                foreach (var x in ddlCity)
                {
                    licities.Add(new SelectListItem { Text = x.City, Value = x.Id.ToString() });
                }
            }
            return Json(new SelectList(licities, "Text", "Value"));

        }


here view
<div class="form-group">
    @Html.LabelFor(model => model.Country, htmlAttributes: new { @class = "control-label col-md-2" })
    <div class="col-md-10">
        @Html.DropDownListFor(model => model.Country, ViewBag.state as List<SelectListItem>, new { style = "width: 200px;" })

        @Html.ValidationMessageFor(model => model.Country, "", new { @class = "text-danger" })
    </div>
</div>

<div class="form-group">
    @Html.LabelFor(model => model.City, htmlAttributes: new { @class = "control-label col-md-2" })
    <div class="col-md-10">
        @Html.DropDownListFor(model => model.City, new SelectList(string.Empty, "Value", "Text"), "--Select City--", new { style = "width:200px" })

        @Html.ValidationMessageFor(model => model.City, "", new { @class = "text-danger" })


here jQuery
$(document).ready(function () {

        $("#Country").change(function () {
            $("#City").empty();
            $.ajax({
                type: 'POST',
                url: '@Url.Action("GetCity")',
                dataType: 'json',
                data: { id: $("#Country").val() },
                success: function (city) {

                    $.each(city, function (i, city) {
                        $("#City").append('<option value="' + city.Value + '">'+ city.Text + '</option>');
             
                    });
                },
                error: function (ex) {
                    alert('Failed.' + ex);
                }
            });
            return false;
        })
    });

AnswerRe: Getting undefined in Cascading DropDownList In ASP.Core MVC ? Pin
Vincent Maverick Durano11-Jul-19 10:12
mveVincent Maverick Durano11-Jul-19 10:12 
GeneralRe: Getting undefined in Cascading DropDownList In ASP.Core MVC ? Pin
Abdalla Ben Omran12-Jul-19 5:12
memberAbdalla Ben Omran12-Jul-19 5:12 
GeneralRe: Getting undefined in Cascading DropDownList In ASP.Core MVC ? Pin
Vincent Maverick Durano12-Jul-19 12:01
mveVincent Maverick Durano12-Jul-19 12:01 
GeneralRe: Getting undefined in Cascading DropDownList In ASP.Core MVC ? Pin
Abdalla Ben Omran13-Jul-19 0:31
memberAbdalla Ben Omran13-Jul-19 0:31 
GeneralRe: Getting undefined in Cascading DropDownList In ASP.Core MVC ? Pin
Vincent Maverick Durano16-Jul-19 9:01
mveVincent Maverick Durano16-Jul-19 9:01 
GeneralRe: Getting undefined in Cascading DropDownList In ASP.Core MVC ? Pin
Abdalla Ben Omran17-Jul-19 3:26
memberAbdalla Ben Omran17-Jul-19 3:26 
GeneralRe: Getting undefined in Cascading DropDownList In ASP.Core MVC ? Pin
Vincent Maverick Durano18-Jul-19 8:00
mveVincent Maverick Durano18-Jul-19 8:00 
QuestionA Potentially Dangerous Request.form Value Was Detected From The Client Pin
Member 1451693730-Jun-19 19:32
memberMember 1451693730-Jun-19 19:32 
AnswerRe: A Potentially Dangerous Request.form Value Was Detected From The Client Pin
F-ES Sitecore30-Jun-19 22:01
mveF-ES Sitecore30-Jun-19 22:01 
GeneralRe: A Potentially Dangerous Request.form Value Was Detected From The Client Pin
Member 1451693730-Jun-19 22:50
memberMember 1451693730-Jun-19 22:50 
GeneralMessage Closed Pin
2-Jul-19 20:49
professionalDds Detective2-Jul-19 20:49 
QuestionHow to read app config in a class library? Pin
Cenk KIZILDAĞ28-Jun-19 4:37
memberCenk KIZILDAĞ28-Jun-19 4:37 
AnswerRe: How to read app config in a class library? Pin
F-ES Sitecore28-Jun-19 4:50
mveF-ES Sitecore28-Jun-19 4:50 
QuestionI am having issues with getting results using dates as parameters Pin
samflex26-Jun-19 3:38
membersamflex26-Jun-19 3:38 
QuestionRe: I am having issues with getting results using dates as parameters Pin
Richard MacCutchan26-Jun-19 6:51
protectorRichard MacCutchan26-Jun-19 6:51 
AnswerRe: I am having issues with getting results using dates as parameters Pin
samflex26-Jun-19 7:12
membersamflex26-Jun-19 7:12 
GeneralRe: I am having issues with getting results using dates as parameters Pin
Richard MacCutchan26-Jun-19 7:27
protectorRichard MacCutchan26-Jun-19 7:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.