Solved

How to display custom disclaimer tag from web.config on asp.net page?

Posted on 2007-04-05
3
1,012 Views
Last Modified: 2012-06-21
I have an ASP .Net form and I want to display a disclaimer info on it from the web.config. The disclaimer can be different and customized for each customer. I want to add a custom tag in web.config like shown below..

<disclaimer>
This software....
line2 of disclaimer..
line3..
can be any number of lines..
</disclaimer>

I investigated the custom configuarion features of asp .net 2.0, but it does not allow multiline data (variable length)  like this..It needs scalar values like these..

<ScottsSettings
     quoteOfTheDay="Hello, World!"
     yourAge="28">
   <favoriteStates>
      <add name="California" abbreviation="CA" />
      <add name="Missouri" abbreviation="MO" />
      <add name="Illinois" />
   </favoriteStates>
</ScottsSettings>

Any ideas on how i could implement this?

Thanks, LM
0
Comment
Question by:LubomirMasar
  • 2
3 Comments
 
LVL 35

Accepted Solution

by:
mrichmon earned 250 total points
ID: 18860219
You could write your own xml file like this

disclaimer.xml
<?xml version="1.0" encoding="utf-8" ?>
<disclaimer>
<![CDATA[
This software....
line2 of disclaimer..
line3..
can be any number of lines..
]]>
</disclaimer>

Note the CDATA should be used if you want multiple lines and/or formatting

Then access like this:
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load("path to your xml file");
string disclaimer = xmlDoc.DocumentElement["disclaimer"].InnerText;
0
 

Author Comment

by:LubomirMasar
ID: 18860507
mrichmon,
In that approach, why deal with XML at all? I could write a simple text file having disclaimer content and then use System.IO streamreader class to read and display on page correct? I had tested this and it works easily. But the customer prefers not to use a separate file, likes to use web.config for all their custom configuration.

I can also do like this

<appSettings>
<add key="DISCLAIMER_LINE1" value="Disclaimer first line"
<add key="DISCLAIMER_LINE2" value="Disclaimer second line"
<add key="DISCLAIMER_LINE3" value="Disclaimer third line"
</appSettings>
 and process like this

string disclaimer = ConfigurationSettings.AppSettings["DISCLAIMER_LINE1"].ToString();
disclaimer = disclaimer + ConfigurationSettings.AppSettings["DISCLAIMER_LINE2"].ToString();

But this is a bit ugly too. We have to decide a max number of lines for disclaimer ahead of time.

Thanks for the response..I think there must be a better way..


0
 
LVL 35

Expert Comment

by:mrichmon
ID: 18861164
>>In that approach, why deal with XML at all? I could write a simple text file having disclaimer content and then use System.IO streamreader class to read and display on page correct

You could.  But what I showed the only difference between that and the web.config is that ConfigurationManager does the xmldocument load lines for you... You could even call it disclaimer.config if you wanted....
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now