Click here to Skip to main content
Click here to Skip to main content

Dynamic Help-System for Web Based Applications

By , 13 May 2010
Rate this:
Please Sign up or sign in to vote.
helpsystem1_small.JPG

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[
<b>This is help manual for default page</b>
]]>
</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();
//set the title bar if pagetitle value is other than 0
ttlHelp.Text = (pageTitle != "0") ? pageTitle : "";
try
{
//creates an instance of XPathDocument class and loads XML
if (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 time
nav = doc.CreateNavigator();
// Compile a standard XPath expression
expr = 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 nodes
while (iterator.MoveNext())
{
//if attribute is not there but node is there, null will be returned
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
{
//when control is returned out of the method, corresponding ref variables are made null
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!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Vinit Kumar Singh
Web Developer HCL Technologies
India India
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.
Follow on   Twitter

Comments and Discussions

 
GeneralYour feedbacks for improvements would be appreciated. PinmemberVinit Kumar Singh13-May-10 18:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140421.2 | Last Updated 13 May 2010
Article Copyright 2010 by Vinit Kumar Singh
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid