Dynamic Help-System for Web based applications



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 anypage by changing the xml file kept at the website folder.



Recently I was asked by 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 anypage by changing any static file kept at the website folder


Using the code

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 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:

"2" url="/Default.aspx" helptitle="Default help title">
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();
//set the title bar if pagetitle value is other than 0ttlHelp.Text = (pageTitle != "0") ? pageTitle : "";
//creates an instance of XPathDocument class and loads xmlif (System.IO.File.Exists(Server.MapPath("/Components/PageHelp.xml")))
doc = new XPathDocument(Server.MapPath("/Components/PageHelp.xml"));
//An XPathNavigator object acts like a cursor, addressing a node in the XML document at a timenav = doc.CreateNavigator();
// Compile a standard XPath expressionexpr = nav.Compile("/Pages/Page[@id=" + pageID + "]/PageHelpText");
iterator = nav.Select(expr);
//if node is found, count would be greater than 0 if (iterator.Count > 0)
//Iterate through the selected nodeswhile (iterator.MoveNext())
//if attribute is not there but node is there,null will be returnedif (iterator.Current.InnerXml != null)
sbHtml.Append("Help:" + pageTitle + "

divHelpParent.InnerHtml = sbHtml.ToString();
Response.Write("Sorry! No help available for this page!");
//when control is returned out of the method, corresponding ref variables are made nullsbHtml = 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 int the xml itself.

You can download the sample from below article I have posted on codeproject: