Introduction
This is a simple and quick help system which pops up page-specific help page on the base of URL. One can change the HTML text of the help anytime for any page by changing the XML file kept at the website folder.
Background
Recently I was asked by a client to develop a simple and quick help system which should be page specific and using which he can change the HTML text of the help anytime for any page by changing any static file kept at the website folder.
Using the Code
The default page is the dummy place from where hyperlink can be clicked to pop up the help for default page. This can be placed at some common place like master page which will bring the page id from XML on the basis of the URL on the address bar and then redirect to DynamicHelp.aspx - the page which is the common page for rendering help for any page.
lnkGetHelp.OnClientClick = "javascript:window.open('DynamicHelp.aspx?" +
GetPageQueryStringsFromXML() + "','DynamicHelp','width=500,height=300,
toolbar=no,scrollbars=yes,resizable=no,dependent=yes');return false;";
This is the page XML I am using for mapping pageid
, url
and title
, please note html
being in CDATA
, I can put any html
there:
<Page id="2" url="/Default.aspx" helptitle="Default help title">
<PageHelpText>
<![CDATA[
</PageHelpText>
</Page>
Then in the Help page, I am fetching the helptext on and title text on the basis of page id and rendering it on HTML page as follows:
XPathDocument doc = null;
XPathNavigator nav = null;
XPathExpression expr = null;
XPathNodeIterator iterator = null;
StringBuilder sbHtml = new StringBuilder();
ttlHelp.Text = (pageTitle != "0") ? pageTitle : "";
try
{
if (System.IO.File.Exists(Server.MapPath("/Components/PageHelp.xml")))
{
doc = new XPathDocument(Server.MapPath("/Components/PageHelp.xml"));
nav = doc.CreateNavigator();
expr = nav.Compile("/Pages/Page[@id=" + pageID + "]/PageHelpText");
iterator = nav.Select(expr);
if (iterator.Count > 0)
{
while (iterator.MoveNext())
{
if (iterator.Current.InnerXml != null)
{
sbHtml.Append("Help:" + pageTitle + "<br/><br/>");
sbHtml.Append(HttpUtility.HtmlDecode(iterator.Current.InnerXml));
divHelpParent.InnerHtml = sbHtml.ToString();
}
}
}
else
{
Response.Write("Sorry! No help available for this page!");
}
}
}
finally
{
sbHtml = null;
pageID = null;
pageTitle = null;
doc = null;
nav = null;
expr = null;
iterator = null;
}
Points of Interest
I liked the efficient way of bringing text from XML using XPathDocument
and the dynamic nature of this tool to add any kind of help text you want into the XML itself.
History
This is the first version, I am sure you guys can give many tips for improvement, waiting for those. Thanks!
Vinit has about eleven years of hands on experience in managing and delivering development solutions using Microsoft technologies. His experience includes analysis, design, coding and implementation, most of it in large-scale OO applications. Has experience in coding, release planning, estimation, capacity planning, tracking and reporting progress. Ability to take business problems and facilitate their solution through collaboration and ingenuity. Experienced in dealing with client stake-holders and managing their expectations. Managing software development teams of 20 and more.
Specialties:
=> Hands-on project management experience that includes responsibility for delivery.
=> Hands-on coding in MS Technologies - VS, C#.net, WCF, MVC, SQL Server, Java Script, XML, JQuery, AJAX.
=> Exp with Third party components - Telerik, Enterprise Library
=> Exp with Source controllers – VSS, TFS, Vault, SVN
=> Exp with UML\PM – MS Visio, MS Project Plan
=> Immense exposure in Client interactions at onsite (TX, UT, NC, FL, HKG) and offshore from Initiation to closing the project.