I am having a lot of trouble converting the following telerik aspx code to the razor view engine. The error I am getting is : ‘CS1012: Too many characters in character literal’ on the first input button.
<% Html.Telerik().Grid(Model)
.Name("Customers")
.DataKeys(dataKeys => dataKeys.Add(c => c.CustomerID))
.Columns(columns =>
{
columns.Bound(c => c.CustomerID).Width(130);
columns.Bound(c => c.CompanyName).Width(250);
columns.Bound(c => c.ContactName);
columns.Bound(c => c.Country).Width(200);
columns.Template(c => {
%> <input type='button' value='Edit' onclick="updateRecord('<%= c.CustomerID %>')" /> <%
%> <input type='button' value='Delete' onclick="deleteRecord('<%= c.CustomerID %>')" /> <%
}).Width(150);
})
.Pageable()
.Sortable()
.Render();
%>
My attempt is as follows:
@{ Html.Telerik().Grid(Model)
.Name("Grid")
.DataKeys(dataKeys => dataKeys.Add(c => c.Id))
.Columns(columns =>
{
columns.Bound(o => o.PartNumber).Width(100);
columns.Template(c => {
} <input type='button' value='Edit' onclick="updateRecord('@c.Id')" /> @{
} <input type='button' value='Delete' onclick="deleteRecord('@c.Id')" /> @{
}).Width(150);
})
.Groupable()
.Sortable()
.Pageable()
.Filterable()
.Render();
}
Thanks
Ryan
You cannot put HTML in an expression like that in Razor.
Instead, use an inline template: