views:

129

answers:

2

In my html, I use Model.Subcontract.company

How can I reference that data in my jQuery?

+1  A: 

Set the value to an html element and then access it via jquery.

<input type="hidden" value="<%= Model.Subcontract.Company %>" id="hidData" name="hidData" />

$("#hidData").val();
Dustin Laine
I wound up doing it this way. Mine was starting to get cumbersome as I got further into it.
RememberME
A: 

I was able to do it like this:

"<%= Model.Subcontract.company %>"

It's always easier to figure it out after you've given up and asked the question!

RememberME
As long as you write the JavaScript inside the View file it will work, but in the future if you put all the JavaScript in a separate .js file it ll stop working, as the .js extensions are not processed by the IIS pipeline, it wont parse the "<% %>" tags anymore unless you do some hacks to the IIS.
Omar