Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > this.Context.Server.MapPath

Reply
Thread Tools

this.Context.Server.MapPath

 
 
crazyhorse
Guest
Posts: n/a
 
      06-10-2005
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;
}

 
Reply With Quote
 
 
 
 
Teemu Keiski
Guest
Posts: n/a
 
      06-10-2005
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.

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke


"crazyhorse" <> wrote in message
news: oups.com...
> 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;
> }
>



 
Reply With Quote
 
 
 
 
crazyhorse
Guest
Posts: n/a
 
      06-10-2005
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.

 
Reply With Quote
 
Teemu Keiski
Guest
Posts: n/a
 
      06-10-2005
Sorry my bad, I meant HttpServerutility (missed the server word)

http://msdn.microsoft.com/library/de...ClassTopic.asp

It has method MapPath

Teemu


 
Reply With Quote
 
Teemu Keiski
Guest
Posts: n/a
 
      06-10-2005
Argh,

I'm tired and speaking holes to my head.

See this one, (free design-time xtension)
http://www.planet-source-code.com/vb...1960&lngWId=10


--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57