In my controller I have
public ActionResult Index()
{
//...
//...
var viewModel = new IndexViewModel()
{
MTohum = mTohum,
STohum = sTohum,
BTohum = bTohum,
TKota = tKota,
KKota = kKota,
BKota = bKota,
};
//return Content("tkota : " + tKota.ToString() + " kkota : " + kKota.ToString() + " bkota : " + bKota.ToString());
return View(viewModel);
}
When I remove comment and return Content() I can see that values are not null.
On the view side:
//..html codes..//
<script>
$(document).ready(function () {
alert(@Model.TKota);
alert(@Model.KKota);
alert(@Model.BKota);
alert(@Model.TKota + " " + @Model.KKota + " " + @Model.BKota);
});
</script>
My problem is: 1st, 2nd and 3rd alerts showing right info but when I trying to take all info in one alert like 4th, I can get @Model.TKota, @Model.KKota but I can't get @Model.BKota value.
Consequently I can't use @Model.BKota in the following lines.
alert("@Model.TKota + " " + @Model.KKota + " " + @Model.BKota);looks like a syntax error,would occur due to the opening " not being closed. Try this:alert(@Model.TKota + " " + @Model.KKota + " " + @Model.BKota);