I’m working on an ASP.NET (C#) web project that is using master pages.
I’m looking for an easy way to display a random customer quote each time a page is loaded.
Since this is a fairly simple web project I’d like to stay away from storing the quotes in a database. Currently there is no database connections required for the project so I’d like to keep it as simple as possible — perhaps storing the quotes in an XML file them using an XmlTextReader to read the file?
Any advice is appreciated.
Thanks
Edit: I will need to store and pull both a quote and a customer name for the quote.
It could be something as simple as this with LINQ:
Your file would be structured like this:
You would load it using
XElement xml = XElement.Load("filename");With the
xmlvariable above, the previous code is used the same way (commented out code).The
Guidworks but you could also have a static Random variable defined in a class:public static Random rand = new Random();then change the code to: