我使用MVC 2和MVC contribgrid

我收到错误为“换行是恒定的”,“预期的标识符”,“; excepeted”在这里我的编码

<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>

它示出了在此引用文字部分错误:**<%** if (ViewData["CustomerInfoList"] !=null && ((List<SaasModel.CustomerInfo>)

有帮助吗?

解决方案 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>

看我的观点,说在那里我做了错误...

其他提示

您确定它是不是 “换行的 IN 的常量”

如果是这样,您确保代码是完全按照此处显示格式化? (即,不存在换行?)

我知道这个问题是旧的,但“接受的答案”是不是在所有的答案,而且我刚刚发现这一点的同时试图找到我自己的小问题的解决方案。

我突然收到类似的错误,这些(“换行中恒”和“预期”)指向一些服务器端代码的几个aspx页面。该代码没有被修改过了一段时间,不存在前所未有的问题,所以这是很奇怪的。我使用VS2012与TFS2012,和我所看到的错误,当我试图让所有项目的最新版本在一个特定的文件夹中。

要解决这个问题,我不得不滚动过去的这些错误,以一个完全不同的aspx.cs页面,在这里我没有封闭的if语句,我正在上找到一个无关的错误。修复此提出的其他错误消失。回想起来,我应该有一个解决方案容易得多找到,但它仍然是很奇怪考虑的事实,我不认为有任何问题与其他网页。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top