This question is an exact duplicate of:
I'm using asp.net mvc to display a .html document that I know exactly what it contains.
I have this method in my controller:
public ActionResult GetHtmlPage(string path)
{
return new FilePathResult(path, "text/html");
}
and I have this Simple view:
@{
ViewBag.Title = "ManageDocument";
}
<h2>ManageDocument</h2>
@Html.Action("GetHtmlPage", "myController", new { path = Model.documentPath })
The document is displayed with no problems. But i want to Highlight a specific sentence that I know it exists somewhere in the document.
What I mean is, I'm trying to implement a JavaScript code maybe to find that specific sentence i want to highlight in the document and highlight it! I read about window.find() in JavaScript but my asp.net solution doesn't seem to recognize it.
I'm using VS2015 Enterprise
You could use jQuery to wrap the text with some tags and apply whatever custom styles you might need. Let's suppose that you have the following markup:
and you want to end up with this:
You could try the
:contains
selector to locate the desired portion of the text and then wrap it with some tags:And here's a
sample fiddle
.