Hi,
Please can someone assist with the following. The view does not receive the values from the script at all. The function does receive values correctly. The textbox and dropdown get called using the id and not generated with Razor.
Thanks
View
<div id="Textbox"></div> // This textbox already exist and cannot use Razor
<div id="DropDown"></div> // This dropdown already exist and cannot use Razor
Script
// The response receives the value from the controller
// The issue is that the view is not getting updated with the values from the script
$(function (response) {
$( url: '@Url.Action("Index", "Home")',
$('#Textbox').html(response.TextboxText); // do receive the correct values
$('#DropDown').html(response.DropDownText); // do receive the correct values
});
});
Model
public class Models
{
public string TextboxText { get; set; }
public string DropDownText { get; set; }
}
Controller
public ActionResult Index(Models models)
{
// Code that recieves data and add it to textValue
if (textName == "SomeTextboxText")
{
models.TextboxText = textValue;
}
if (textName == "SomeDropDownText")
{
models.DropDownText = textValue;
}
return Json(models);
}