简体   繁体   中英

Modify Existing HTML Table

I have an HTML table that I request from a webserver in C#. I am then displaying the page in my aspx webform. How can I add a prerequisite based on the course ID to the last column in the table without hard-coding the prerequisite? Example of the table design is below.

<tr bgcolor="#E1E1CC">
   <td width="7%">003597</td>
   <td width="5%">01</td>
   <td width="1%">OPT</td>
   <td width="8%">MT H   </td>
   <td width="16%">2:00 pm - 2:50 pm  </td>
   <td width="17%">08/26/13 - 12/12/13</td>
   <td width="8%">
       <a href="http://www.mnsu.edu/registrar/building.html"target = _blank>
           <b>TR C124</b>
       </a>
   </td>
   <td width="19%">Staff</td>
   <td width="4%">22</td>
   <td width="4%">6</td>
   <td width="4%"><font color="#000000">Open</font></td>
   <td width="7%">
        <a href=Notes.asp?SpclNote=20143+003597+IT+100 target = _blank>
           <b>Notes</b>
        </a>
   </td>
</tr> 
<tr bgcolor="#E1E1CC">
    <td colspan="3">&nbsp;</td>
    <td width="8%">M      </td>
    <td width="16%">10:00 am - 11:50 am</td>
    <td width="17%">08/26/13 - 12/09/13</td>
    <td width="8%">
        <a href="http://www.mnsu.edu/registrar/building.html"target = _blank>
            <b>WH 0119       </b>
        </a>
    </td>
    <td width="19%">Staff</td>
    <td colspan="4">&nbsp;</td>
</tr>

在此处输入图片说明

If you are getting the page html as a string you could just insert your html into it. Something like:

private void SetValue(string PageHtml, string ID, string TextToInsert)
{
    string html = PageHtml;
    string sMyHtmlToInsert = TextToInsert;
    int iSplitIndex = html.IndexOf(ID);
    iSplitIndex = html.IndexOf("{tag}",iSplitIndex);
    string sHtml1 = html.SubString(0, iSplitIndex);
    string sHtml2 = html.SubString(iSplitIndex);
    string sFinalHtml = sHtml1 + sMyHtmlToInsert + sHtml2;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM