how can I use my own c#(MVC5, ASP.NET 4.5.1) variable in jquery ? Something like that:
$(function () {
@if (Model != null && Model.Count() > 0){
int carrier = Model.Count;
}
if (location.hash = "#DHLNational") {
$("#faq-cat-1-sub-0").show(800);
alert(@carrier);
}
});
I get the following error message:
Error 8 "The name 'carrier' does not exist in the current context"
Ok, but if I do it like this:
$(function () {
@if (Model != null && Model.Count() > 0){
int carrier = Model.Count;
if (location.hash = "#DHLNational") {
$("#faq-cat-1-sub-0").show(800);
alert(@carrier);
}
}
});
Visual studio does not understand jquery anymore. Thanks...
carrierinto a hidden field and select that like any other element? Mixing your Razor and JQuery doesn't feel right.int carrier = "<%=Model.Count%>";?