2014-05-13 73 views
0

有此代碼。以cs1002異常爲例:「預期的」;我做錯了什麼?Asp.net CS1002「;預計」

<% 
     foreach (var rubric in RubricTreeView.Nodes) 
     { %> 
      <div class="rubric-list-item top-level" data-id="<%rubric.Id%>"> 
       <span class="rubric-list-chb"> 
        <input type="checkbox" id="chb<%rubric.Id%>" />  
        <label class="checkbox-skin" for="chb<%rubric.Id%>"></label> 
       </span> 
       <span class="rubric-list-marker active"></span> 
       <%rubric.Title%> 
      </div> 
      <% if (rubric.SubNodes.Any()) 
       { %> 
         <div class="rubric-list-subitems"> 
          <% foreach (var subRubric in rubric.SubNodes) 
          {%> 
           <div class="rubric-list-item active"> 
            <span class="rubric-list-chb"> 
             <input type="checkbox" id="chb<%subRubric.Id%>" /> 
             <label class="checkbox-skin" for="chb<%subRubric.Id%>"></label> 
            </span> 
            <span class="rubric-list-marker"></span> 
            <%subRubric.Title%> 
           </div> 
          <%} %> 
         </div> 
      <% } %> 
    <% } %> 

也許<%subRubric.Title;%>?

+0

此錯誤在哪一行發生? –

回答

3

你應該使用:

<%= rubric.Title %> 

<%= subRubric.Title %> 

,並在一些地方

<%= rubric.Id %> 

否則,裏面的代碼將被評估爲代碼塊,這意味着它需要;

+0

<%= rubric.Id%>和<%= subRubric.Title%> - 換句話說,屬性應該與<%= %> – Alex