Say I have a control that is used on 10 different pages, and this control has a help icon. Each page should display it's own help text -which is about a paragraph each. Which help text to show is selected by a JavaScript function.
I realize in my case 10 paragraphs will not be a significant performance hit; however for the sake of knowledge, what would be the best implementation? Save the text in a server control -such as a HiddenField- or straight in the JavaScript?
If I had to create a DB-less solution, I would do one of three things:
Option 1
Store the text in an XML file that can be read by your web application.
<?xml version="1.0" encoding="utf-8" ?>
<HelpTexts>
<HelpText name="HelpText1">
Some help text
</HelpText>
...
</HelpTexts>
Option 2
Store the text in the web.config
.
<add key="HelpText1" value="[Some help text" />
var foo = WebConfigurationManager.AppSettings["HelpText1"];
Option 3
Store the text in the template that's using the control and set it as a property. This is my preference because it's relatively clean and allows the control to be used on another page quickly and easily.
protected void Page_Load(object sender, EventArgs e)
{
myControl.HelpText = "[Some help text]";
}