0

我正在使用 mvc 2 和 mvc contribgrid

我收到错误,因为“换行符是常量”,“预期标识符”,“;例外”这是我的编码

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

它在此 Blockquotes 部分显示错误:**<%** if (ViewData["CustomerInfoList"] !=null && ((List<SaasModel.CustomerInfo>)

4

3 回答 3

0

我知道这个问题很老,但“接受的答案”根本不是答案,我只是在试图为自己的小问题找到解决方案时发现了这一点。

我突然收到与这些(“换行符不变”和“;预期”)类似的错误,这些错误指向一些 aspx 页面上的一些服务器端代码。那段代码已经有一段时间没有修改了,之前也没有出现过问题,所以很奇怪。我将 VS2012 与 TFS2012 一起使用,当我尝试获取特定文件夹中所有项目的最新版本时,我看到了错误。

为了解决这个问题,我只需要滚动这些错误,就可以在完全不同的 aspx.cs 页面上找到一个不相关的错误,我没有关闭我正在处理的 if 语句。修复此问题使其他错误消失。回想起来,我应该更容易找到解决方案,但考虑到我认为其他页面没有任何问题,这仍然很奇怪。

于 2013-01-05T00:08:19.600 回答
0
<%@ 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>

看看我的观点并说出我在哪里做错了......

于 2010-11-24T04:10:32.497 回答
0

你确定它不是“Newline IN constant”吗?

如果是这样,您确定代码的格式与此处显示的完全相同吗?(即没有换行符?)

于 2010-11-23T11:14:32.957 回答