this.Context.Server.MapPath

C

crazyhorse

can get the Server.MapPath to work in run-mode, but not in the property
desinger window. It will throw an error. Try to read a xml file in
the Oninit. Works when you run a web page, but not while you open the
desinger properties window. What am i doing wrong, or is this is just
the way a control works. How can i initialize my property from a xml
file, without being in run mode.



protected override void OnInit(EventArgs e)
{
base.OnInit(e);
string ss="";
try
{
ss=this.Context.Server.MapPath("myxmlfile.xml");


}
catch
{

}
text2=ss;
}
 
T

Teemu Keiski

MapPath cannot because it exists when there is a HttpContext alive (which
isn't the case in design mode) but you can use HttpUtility class during
design mode.
 
C

crazyhorse

Context.Server.MapPath­("myxmlfile.xml");

What is the HttpUtility to make the above code work in design-mode.
Looked up HttpUtility class. It is something like to convert a string
to HTML format and back again? Seems there is a bunch of methods like
HttpUtility.HtmlDecode and HtmlEncode and such.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top