Member 8478234 Ответов: 1

Как использовать, если внутри MVC razor


У меня возникла проблема, когда по какой-то причине оператор if не распознается и вместо этого печатается в виде текста. Пожалуйста, помогите мне.

<style type="text/css">
    table, td, th {
        border: 1px solid black;
    }

    table {
        border-collapse: collapse;
        width: 100%;
        font-size: 9px;
    }

    th {
        height: 50px;
    }

    body {
        font-family: Verdana !important;
    }
</style>

<div style="font-family: Verdana !important;">Hi,</div><br>

<div style="font-family: Verdana !important;">Request you to provide the ESA Invoice nos. for the below On account</div><br>

<table>
    <tr style="background-color:#D4E9FB; font-weight:bold;">
        <td>CUSTOMER_ID</td>
        <td>CUSTOMER</td>
        <td>PAYMENT_ID</td>
        <td>PAYMENT_CURRENCY</td>
        <td>PAYMENT_AMOUNT</td>
        <td>OA</td>
        <td>OA_DATE/td>
        <td>OA_CURRENCY/td>
        <td>OA_BALANCE_AMOUNT/td>
        <td>OA_REMARKS/td>
    </tr>
    <tr>
            <td>1211758</td>
            <td>Credit Suisse AG, Singapore Branch</td>
            <td>SG0010000214879</td>
            <td>SGD</td>
            <td align="right">3,865,778.08</td>
            <td>OA-43452</td>
            <td>22-Jun-16</td>
            <td>SGD</td>
            <td align="right">(3,695,521.14)</td>
            <td>VIPS</td>
    </tr>
</table>


    if (Model.BankTemplateParts1.length > 0 && Model.WorkFileTemplates.length > 0)
    {
<br><div>The bank extract and the working for the OA is attached below</div><br>
    }
    else if (Model.BankTemplateParts1.length > 0 && Model.WorkFileTemplates.length == 0)
    {
<br><div>The bank extract for the OA is attached below</div><br>
    }
    else if (Model.BankTemplateParts1.length == 0 && Model.WorkFileTemplates.length > 0)
    {
<br><div>The working for the OA is attached below</div><br>
    }


    if (Model.BankTemplateParts1.Count > 0)
    {
<table>
    <tr style="background-color:#87CEFA; font-weight:bold;">
        <td>BANK_ID</td>
        <td>BANK_NAME</td>
        <td>CURRENCY</td>
        <td>ACCOUNT_NUMBER</td>
        <td>ENTITY_ID</td>
        <td>ACCOUNT_NAME</td>
        <td>TRANSACTION_DATE</td>
        <td>VALUE_DATE</td>
        <td>DESCRIPTION</td>
        <td>CUSTOMER_REFERENCE</td>
        <td>BANK_REFERENCE</td>
    </tr>
    
            <tr>
                <td>CHASSGSG</td>
                <td>JPMorgan Chase Bank, NA Singapore</td>
                <td>SGD</td>
                <td>8830007033</td>
                <td>MA311</td>
                <td>COGNIZANT TECH SOL ASIA PAC PTE LTD</td>
                <td>6/22/2016</td>
                <td>6/22/2016</td>
                <td>AUTOPAY - CR.</td>
                <td>SG0010000214879</td>
                <td>LSG6174024578410</td>
            </tr>
            
</table><br>

<table>
    <tr style="background-color:#87CEFA; font-weight:bold;">
        <td align="right">CREDIT_AMOUNT</td>
        <td align="right">DEBIT_AMOUNT</td>
        <td>IMMEDIATE_AVAILABLE</td>
        <td>1_DAYFLOAT</td>
        <td>2_DAYFLOAT</td>
        <td>2+DAYFLOAT</td>
        <td>3+DAYFLOAT</td>
        <td>REMARKS_1</td>
        <td>REMARKS_2</td>
        <td>REMARKS_3</td>
        <td>REMARKS_4</td>
        <td>REMARKS_5</td>
    </tr>
    
            <tr>
                <td>3,865,778.08</td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td>YOUR REF    =SG0010000214879</td>
                <td>B/O CUSTOMER=CREDIT SUISSE AG</td>
                <td>PAY METHOD  =INTERBANK GIRO</td>
                <td>PAYDET      =SG0010000214879PurpCd-OTHR                 RmtInf-CS PAYMENT REF 0000214879</td>
                <td></td>
            </tr>
            
</table><br>

<table>
    <tr style="background-color:#87CEFA; font-weight:bold;">
        <td>REMARKS_6</td>
        <td>REMARKS_7</td>
        <td>REMARKS_8</td>
        <td>REMARKS_9</td>
        <td>REMARKS_10</td>
        <td>REMARKS_11</td>
        <td>REMARKS_12</td>
        <td>REMARKS_13</td>
        <td>REMARKS_14</td>
        <td>REMARKS_15</td>
        <td>TRANSACTION_TIME</td>
    </tr>
  
            <tr>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td>03:57 AM</td>
            </tr>
            
</table><br>

        if (Model.WorkFileTemplates.Count > 0)
        {
<table>
    <tr style="background-color:#49A4F3; font-weight:bold;">
        <td>INVOICE_NUMBER</td>
        <td>AMT_RECEIVED</td>
        <td>AMOUNT_O/S</td>
        <td>BALANCE_IN_INVOICE_AFTER_ADJUSTMENT</td>
        <td>DIFFERENCE</td>
        <td>CURRENCY</td>
        <td>BU_DESCRIPTION</td>
        <td>CUSTOMER_ID</td>
        <td>CUSTOMER_NAME</td>
        <td>CONSOLIDATED</td>
        <td>DEPOSIT</td>
    </tr>
   
            <tr>
                <td>US410-0001205867</td>
                <td align="right">14,540.00</td>
                <td align="right">14,540.00</td>
                <td align="right">-  </td>
                <td>-  </td>
                <td>USD</td>
                <td>MLEU - NA</td>
                <td>1200950</td>
                <td>Toyota Motor Sales- U.S.A. Inc.</td>
                <td></td>
                <td></td>
            </tr>
            <tr>
                <td>US410-0001214883</td>
                <td align="right">15,960.00</td>
                <td align="right">15,960.00</td>
                <td align="right">-  </td>
                <td>-  </td>
                <td>USD</td>
                <td>MLEU - NA</td>
                <td>1200950</td>
                <td>Toyota Motor Sales- U.S.A. Inc.</td>
                <td></td>
                <td></td>
            </tr>
            <tr>
                <td>US410-0001214886</td>
                <td align="right">15,960.00</td>
                <td align="right">15,960.00</td>
                <td align="right">-  </td>
                <td>-  </td>
                <td>USD</td>
                <td>MLEU - NA</td>
                <td>1200950</td>
                <td>Toyota Motor Sales- U.S.A. Inc.</td>
                <td></td>
                <td></td>
            </tr>
            <tr>
                <td></td>
                <td align="right">46,460.00</td>
                <td align="right">46,460.00</td>
                <td align="right"></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
            </tr>
           
</table><br>


<br /><br /><br><div><b>Thank You,<br>Team Receivables</b></div>


Что я уже пробовал:

<style type="text/css">
    table, td, th {
        border: 1px solid black;
    }

    table {
        border-collapse: collapse;
        width: 100%;
        font-size: 9px;
    }

    th {
        height: 50px;
    }

    body {
        font-family: Verdana !important;
    }
</style>

<div style="font-family: Verdana !important;">Hi,</div><br>

<div style="font-family: Verdana !important;">Request you to provide the ESA Invoice nos. for the below On account</div><br>

<table>
    <tr style="background-color:#D4E9FB; font-weight:bold;">
        <td>CUSTOMER_ID</td>
        <td>CUSTOMER</td>
        <td>PAYMENT_ID</td>
        <td>PAYMENT_CURRENCY</td>
        <td>PAYMENT_AMOUNT</td>
        <td>OA</td>
        <td>OA_DATE/td>
        <td>OA_CURRENCY/td>
        <td>OA_BALANCE_AMOUNT/td>
        <td>OA_REMARKS/td>
    </tr>
    <tr>
            <td>1211758</td>
            <td>Credit Suisse AG, Singapore Branch</td>
            <td>SG0010000214879</td>
            <td>SGD</td>
            <td align="right">3,865,778.08</td>
            <td>OA-43452</td>
            <td>22-Jun-16</td>
            <td>SGD</td>
            <td align="right">(3,695,521.14)</td>
            <td>VIPS</td>
    </tr>
</table>


    if (Model.BankTemplateParts1.length > 0 && Model.WorkFileTemplates.length > 0)
    {
<br><div>The bank extract and the working for the OA is attached below</div><br>
    }
    else if (Model.BankTemplateParts1.length > 0 && Model.WorkFileTemplates.length == 0)
    {
<br><div>The bank extract for the OA is attached below</div><br>
    }
    else if (Model.BankTemplateParts1.length == 0 && Model.WorkFileTemplates.length > 0)
    {
<br><div>The working for the OA is attached below</div><br>
    }


    if (Model.BankTemplateParts1.Count > 0)
    {
<table>
    <tr style="background-color:#87CEFA; font-weight:bold;">
        <td>BANK_ID</td>
        <td>BANK_NAME</td>
        <td>CURRENCY</td>
        <td>ACCOUNT_NUMBER</td>
        <td>ENTITY_ID</td>
        <td>ACCOUNT_NAME</td>
        <td>TRANSACTION_DATE</td>
        <td>VALUE_DATE</td>
        <td>DESCRIPTION</td>
        <td>CUSTOMER_REFERENCE</td>
        <td>BANK_REFERENCE</td>
    </tr>
    
            <tr>
                <td>CHASSGSG</td>
                <td>JPMorgan Chase Bank, NA Singapore</td>
                <td>SGD</td>
                <td>8830007033</td>
                <td>MA311</td>
                <td>COGNIZANT TECH SOL ASIA PAC PTE LTD</td>
                <td>6/22/2016</td>
                <td>6/22/2016</td>
                <td>AUTOPAY - CR.</td>
                <td>SG0010000214879</td>
                <td>LSG6174024578410</td>
            </tr>
            
</table><br>

<table>
    <tr style="background-color:#87CEFA; font-weight:bold;">
        <td align="right">CREDIT_AMOUNT</td>
        <td align="right">DEBIT_AMOUNT</td>
        <td>IMMEDIATE_AVAILABLE</td>
        <td>1_DAYFLOAT</td>
        <td>2_DAYFLOAT</td>
        <td>2+DAYFLOAT</td>
        <td>3+DAYFLOAT</td>
        <td>REMARKS_1</td>
        <td>REMARKS_2</td>
        <td>REMARKS_3</td>
        <td>REMARKS_4</td>
        <td>REMARKS_5</td>
    </tr>
    
            <tr>
                <td>3,865,778.08</td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td>YOUR REF    =SG0010000214879</td>
                <td>B/O CUSTOMER=CREDIT SUISSE AG</td>
                <td>PAY METHOD  =INTERBANK GIRO</td>
                <td>PAYDET      =SG0010000214879PurpCd-OTHR                 RmtInf-CS PAYMENT REF 0000214879</td>
                <td></td>
            </tr>
            
</table><br>

<table>
    <tr style="background-color:#87CEFA; font-weight:bold;">
        <td>REMARKS_6</td>
        <td>REMARKS_7</td>
        <td>REMARKS_8</td>
        <td>REMARKS_9</td>
        <td>REMARKS_10</td>
        <td>REMARKS_11</td>
        <td>REMARKS_12</td>
        <td>REMARKS_13</td>
        <td>REMARKS_14</td>
        <td>REMARKS_15</td>
        <td>TRANSACTION_TIME</td>
    </tr>
  
            <tr>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td>03:57 AM</td>
            </tr>
            
</table><br>

        if (Model.WorkFileTemplates.Count > 0)
        {
<table>
    <tr style="background-color:#49A4F3; font-weight:bold;">
        <td>INVOICE_NUMBER</td>
        <td>AMT_RECEIVED</td>
        <td>AMOUNT_O/S</td>
        <td>BALANCE_IN_INVOICE_AFTER_ADJUSTMENT</td>
        <td>DIFFERENCE</td>
        <td>CURRENCY</td>
        <td>BU_DESCRIPTION</td>
        <td>CUSTOMER_ID</td>
        <td>CUSTOMER_NAME</td>
        <td>CONSOLIDATED</td>
        <td>DEPOSIT</td>
    </tr>
   
            <tr>
                <td>US410-0001205867</td>
                <td align="right">14,540.00</td>
                <td align="right">14,540.00</td>
                <td align="right">-  </td>
                <td>-  </td>
                <td>USD</td>
                <td>MLEU - NA</td>
                <td>1200950</td>
                <td>Toyota Motor Sales- U.S.A. Inc.</td>
                <td></td>
                <td></td>
            </tr>
            <tr>
                <td>US410-0001214883</td>
                <td align="right">15,960.00</td>
                <td align="right">15,960.00</td>
                <td align="right">-  </td>
                <td>-  </td>
                <td>USD</td>
                <td>MLEU - NA</td>
                <td>1200950</td>
                <td>Toyota Motor Sales- U.S.A. Inc.</td>
                <td></td>
                <td></td>
            </tr>
            <tr>
                <td>US410-0001214886</td>
                <td align="right">15,960.00</td>
                <td align="right">15,960.00</td>
                <td align="right">-  </td>
                <td>-  </td>
                <td>USD</td>
                <td>MLEU - NA</td>
                <td>1200950</td>
                <td>Toyota Motor Sales- U.S.A. Inc.</td>
                <td></td>
                <td></td>
            </tr>
            <tr>
                <td></td>
                <td align="right">46,460.00</td>
                <td align="right">46,460.00</td>
                <td align="right"></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
            </tr>
           
</table><br>


<br /><br /><br><div><b>Thank You,<br>Team Receivables</b></div>

1 Ответов

Рейтинг:
1

Member 7870345

Привет:
Я думаю, что проблема в том, что вы используете if вместо @if.

Кроме того, вы должны учитывать, что при использовании if и else всегда необходимо вставлять скобки staments (даже если это не обязательно в c#).

Например if (condicion) stament1 else stament2 не получится, но

@if (condicion) <br />
  {<br />
     stament1<br />
  }<br />
  else {<br />
     stament2<br />
  }  <br />

будет работать.