tags:

views:

118

answers:

3

I noticed if I start doing this:

var companyID = <% %>;

I don't get any intellisense letting me access my Model.object that the view is suppose to have available to me since it is strongly typed.

What am I missing here?

A: 

Nothing particularly it's just the mixing of syntax that throws the IDE off, since you are in a javascript context the IDE it is trying to account for javascript syntax. It will likely throw off the majority of intellisense within that context because it doesn't know (yet hopefully) what the <% %> should equate to logically within javascript. There are some things you can do to "hack" around this like setting up a facade javascript object that mirrors the view and have the object return the view values although for most cases this is well more work than it is worth.

Quintin Robinson
A: 

It will work at the end of the day.

But maybe you can use a JavaScriptResult controller

Ahmed Khalaf
+1  A: 

The intellisense support for javascript is a little sketchy as it is. Make sure you set it up correctly. i just used this guide, and it at least it's giving javascript intellisense.

now, to test your question, i just put the following on one of my pages:

    <script type="text/javascript">
    var test = <%= Model.Site.SiteID %>;
    document.write(test);
</script>

and it did indeed write the SiteID out. no intellisense for the model, but it does work. hope that helps some.

Jamie M