Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Dec 07, 2012 12:08 PM by GorillaMann
Member
117 Points
332 Posts
Dec 03, 2012 05:27 PM|LINK
Is there a better way to render this? the <text> looks messy
<script> $(document).ready(function() { @foreach (Company item in Model) { <text> $("#progressbar@(item.Id)").progressbar({</Text> @item.FundingCompletedInt() ; <text> })</text> }; }); </script>
All-Star
154927 Points
19867 Posts
Moderator
MVP
Dec 04, 2012 06:02 AM|LINK
You can use @: to render literal text:
@foreach(Company item in Model){ @:$('#progressbar@(item.Id)').progressbar({@(item.FundingCompletedInt());}); }
Dec 04, 2012 08:35 AM|LINK
thanks but I get syntax errors:
<script> $(document).ready(function() { @foreach (Company item in Model) { @: $("#progressbar@(item.Id)").progressbar({ value: @(item.FundingCompletedInt()); }); } }); </script>
Dec 04, 2012 08:47 AM|LINK
More detail please? What errors? What should the output of FundingCompletedInt be? Is that a method? If it's a property, remove the brackets from the end of it.
<script> $(document).ready(function() { @foreach (Company item in Model) { @: $("#progressbar@(item.Id)").progressbar({ value: @(item.FundingCompletedInt); }); } }); </script>
Dec 07, 2012 07:28 AM|LINK
Hi and thanks!
well this item.FundingCompletedInt() is an int between 0 and 100
@:$("#progressbar@(item.Id)").progressbar({ value: @(item.FundingCompletedInt()); });
should output something like this:
$("#progressbar1").progressbar({ value: 10}) I get an error after the first ; after FundingCompletedInt()
Dec 07, 2012 11:51 AM|LINK
GorillaMann well this item.FundingCompletedInt() is an int between 0 and 100
Do you mean it is a method?
GorillaMann I get an error
What error?
Dec 07, 2012 12:08 PM|LINK
Yes its a method.
All the error says is syntax error in visual studio. The page rendes fine though, probably a bug in VS
GorillaMann
Member
117 Points
332 Posts
Mixing Razor and JS in loop
Dec 03, 2012 05:27 PM|LINK
Is there a better way to render this? the <text> looks messy
<script> $(document).ready(function() { @foreach (Company item in Model) { <text> $("#progressbar@(item.Id)").progressbar({</Text> @item.FundingCompletedInt() ; <text> })</text> }; }); </script>Mikesdotnett...
All-Star
154927 Points
19867 Posts
Moderator
MVP
Re: Mixing Razor and JS in loop
Dec 04, 2012 06:02 AM|LINK
You can use @: to render literal text:
@foreach(Company item in Model){ @:$('#progressbar@(item.Id)').progressbar({@(item.FundingCompletedInt());}); }Beginning ASP.NET Web Pages with WebMatrix | My Site | Twitter
GorillaMann
Member
117 Points
332 Posts
Re: Mixing Razor and JS in loop
Dec 04, 2012 08:35 AM|LINK
thanks but I get syntax errors:
<script> $(document).ready(function() { @foreach (Company item in Model) { @: $("#progressbar@(item.Id)").progressbar({ value: @(item.FundingCompletedInt()); }); } }); </script>Mikesdotnett...
All-Star
154927 Points
19867 Posts
Moderator
MVP
Re: Mixing Razor and JS in loop
Dec 04, 2012 08:47 AM|LINK
More detail please? What errors? What should the output of FundingCompletedInt be? Is that a method? If it's a property, remove the brackets from the end of it.
<script> $(document).ready(function() { @foreach (Company item in Model) { @: $("#progressbar@(item.Id)").progressbar({ value: @(item.FundingCompletedInt); }); } }); </script>Beginning ASP.NET Web Pages with WebMatrix | My Site | Twitter
GorillaMann
Member
117 Points
332 Posts
Re: Mixing Razor and JS in loop
Dec 07, 2012 07:28 AM|LINK
Hi and thanks!
well this item.FundingCompletedInt() is an int between 0 and 100
@:$("#progressbar@(item.Id)").progressbar({ value: @(item.FundingCompletedInt()); });
should output something like this:
$("#progressbar1").progressbar({ value: 10})
I get an error after the first ; after FundingCompletedInt()
Mikesdotnett...
All-Star
154927 Points
19867 Posts
Moderator
MVP
Re: Mixing Razor and JS in loop
Dec 07, 2012 11:51 AM|LINK
Do you mean it is a method?
What error?
Beginning ASP.NET Web Pages with WebMatrix | My Site | Twitter
GorillaMann
Member
117 Points
332 Posts
Re: Mixing Razor and JS in loop
Dec 07, 2012 12:08 PM|LINK
Yes its a method.
All the error says is syntax error in visual studio. The page rendes fine though, probably a bug in VS