0

I have an html page for a preview functionality. I pass this as html into a stringbuilder type object and replace content through another page. Now I want a certain section to be hidden under a specific circumstnace. Currently that section is a row. So how can I do so?

The following code in the section I want to hide:

<tr id="rowcontent" bgcolor="E96F00">
<td style="font-family: Arial; font-size: 14px; font-weight: Bold; color:white;">Course Content Link</td>
</tr>
<tr>
<td style="font-family: calibri; font-size: 14px;">@CourseContent@<BR>&nbsp;</td>
</tr>

This is how I am using the above html :

file = Server.MapPath(".") + "\\Template\\Level100_Template.htm";
string input = string.Empty;
if (File.Exists(file))
{
sr = File.OpenText(file);
//input += Server.HtmlEncode(sr.ReadToEnd());
input += sr.ReadToEnd();
x.Append(input);
sr.Close();
}

This is how I am replacing the content section:

if (dt.Rows[0]["CourseContentPath"].ToString() != string.Empty)
    {x.Replace   ("@CourseContent@", "<A href='" +CourseContentLink   + "' target=_blank onclick='window.open(this.href,           this.target,'height=1000px,width=1000px'); return false>Click here</A> to find the course content");
    }

How can I hide the entire section in a particular case..

2
  • Do u wanna find that rows in x and remove them?
    – Amir
    Sep 28, 2012 at 10:20
  • Yes..or any other way..I need to hide that section-that is the motive.
    – Richa
    Sep 28, 2012 at 10:42

1 Answer 1

0

A simplest way is to use this code

string StartStr= "<tr id=\"rowcontent\"", EndStr= "</tr>", String= x.ToString();
int Start= String.IndexOf(StartStr);
int End= String.IndexOf(EndStr, String.IndexOf(EndStr, Start)+ EndStr.Length);
x.Remove(Start,End- Start+ EndStr.Length);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.