Question

i am using mvc 2 and mvc contribgrid

I am Getting error as "Newline is constant","identifier expected",";excepeted" here is my coding

<table cellpadding="0" cellspacing="0" width="100%">
    <% if (ViewData["CustomerInfoList"] !=null && ((List<SaasModel.CustomerInfo>)ViewData["CustomerInfoList"]).Count()>0)
       {
    %>
    <tr>
        <td>
            <%  Html.Grid((List<SaasModel.CustomerInfo>)ViewData["CustomerInfoList"]).Columns(
        column=>
            {
                column.For(col=>col.CustomerName).Named("Name");
                column.For(col=>col.CompanyName).Named("CompanyName");
                column.For(col=>col.Description).Named("Description");
                column.For(col=>col.CustomerRevenue).Named("CustomerRevenue");
                column.For(col=>col.NoOfEmployees).Named("NoOfEmployees");
                column.For(col=>col.Vertical).Named("Vertical");
                column.For(col=>col.SaleExecutive).Named("SaleExecutive");
            }).Attributes(id=>"datalist",@class=>"silicaGrid",cellspacing=>"1",cellpadding=>"0").Render();
            %>
        </td>
    </tr>
    <%}%>
</table>

it shows error in this Blockquotes part:**<%** if (ViewData["CustomerInfoList"] !=null && ((List<SaasModel.CustomerInfo>)

Was it helpful?

Solution 2

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="CelloSaaS.View.CelloViewPage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<h2>
    CustomerInfoList</h2>
<a href="CustomerInfo.aspx" title="Add">
    <img src="<%=this.ResolveClientUrl../../App_Themes/CelloSkin/btn-add.gif")%>" alt="Add" />
</a>
<table cellpadding="0" cellspacing="0" width="100%">
    <% if (ViewData["CustomerInfoList"] !=null && ((List<SaasModel.CustomerInfo>)ViewData["CustomerInfoList"]).Count()>0)
       {
    %>
    <tr>
        <td>
            <%  Html.Grid((List<SaasModel.CustomerInfo>)ViewData["CustomerInfoList"]).Columns(
        column=>
            {
                column.For(col=>col.CustomerName).Named("Name");
                column.For(col=>col.CompanyName).Named("CompanyName");
                column.For(col=>col.Description).Named("Description");
                column.For(col=>col.CustomerRevenue).Named("CustomerRevenue");
                column.For(col=>col.NoOfEmployees).Named("NoOfEmployees");
                column.For(col=>col.Vertical).Named("Vertical");
                column.For(col=>col.SaleExecutive).Named("SaleExecutive");
            }).Attributes(id=>"datalist",@class=>"silicaGrid",cellspacing=>"1",cellpadding=>"0").Render();
            %>
        </td>
    </tr>
    <%}%>
</table>

see my view and say where i have done mistake...

OTHER TIPS

Are you sure it is not "Newline IN constant" ?

If so, are you sure the code is formatted exactly as it is displayed here? (i.e. there are no line breaks?)

I know this question is old, but the "accepted answer" isn't an answer at all, and I just found this while trying to find a solution for my own minor issue.

I was suddenly getting similar errors to these ("Newline in constant" and "; expected") pointing to some serverside code on a few aspx pages. That code had not been modified for a while and there was never an issue before, so it was quite strange. I'm using VS2012 with TFS2012, and I was seeing the errors when I tried to get the latest version on all items in a particular folder.

To solve the problem, I just had to scroll past those errors to find an unrelated error on a completely different aspx.cs page, where I hadn't closed an if statement that I was working on. Fixing this made the other errors disappear. Looking back, I should have found a solution much more easily, but it was still very strange considering the fact that I don't think there's any issue with those other pages.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top