Question

I am working in mvc 4 C#.net 4.0, Visual Studio 2013.

I am using jQuery template. As i am new to mvc and jquery and also for template

Here is my script for template.

I have add this

<script src="~/Scripts/jquery.tmpl.js"></script>
<script src="~/Scripts/jquery.tmpl.min.js"></script>

<script type="text/x-jquery-tmpl" id="ScheduleRowTemplate">
    <tr>
        <td>
            @Html.Label("", ${RowNo}, new { style = "width:100%" })
            <input type="hidden" id="ItemIndex" value="${ItemIndex}" />
        </td>
    </tr>
</script>

In this script, Visual Studio generating error on $ signs.

Unexpected character '$'

What should i do to remove this error? which thing i am missing here ?

Était-ce utile?

La solution

You can't mix a server-side method like Html.Label with a client-side variable like ${RowNo}. Use HTML markup instead of the Razor helpers:

<script type="text/x-jquery-tmpl" id="ScheduleRowTemplate">
    <tr>
        <td>
            <label style="width: 100%">${RowNo}</label>
            <input type="hidden" id="ItemIndex" value="${ItemIndex}" />
        </td>
    </tr>
</script>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top