UserControl Properties

G

Guest

Hello all,

I have a usercontrol with a number of public properties. A couple of these
properties are file paths (to xml files, etc). These file paths may be to any
folder in my project.

However, when setting these using xmlfile="~/thexmlfile.xml" it doesn't seem
to work. If I do a debug at the point is does the set, is coming through as
"~/thexmlfile.xml" rather than the actual application path. Why is this and
is there a work around? I've also tried doing a contect swith to a method
that would return the application path, eg
xmlfile="<%=MyAppPathMethod%>/thexmlfle.xml", but alas this didn't wotk.

Any help, would be much appreciated,

Jon
 
W

William F. Robertson, Jr.

You should use Server.MapPath.

string XmlFile = Server.MapPath( "~/thexmlfile.xml" ).

it will get the actual path on your server.

HTH,

bill
 

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

Top