Wednesday, March 21, 2012

a issue in <atlas:UpdatePanel>:do not work with .css file in format of absolute path

i found a issue in <atlas:UpdatePanel> control, under <ContentTemplate> control, we usually put lots of html control or server control, withclass attribute orcssclass attribute.

if the .css file is in a format ofabsolute path like below

<link type="text/css" rel="stylesheet" href="/myWeb/css/RichClientUI.css"/
then the partial render html tagcan not apply style setting defined in .css file.

if the .css file is in a format of relative path like below

<link type="text/css" rel="stylesheet" href="../../css/RichClientUI.css"/>

then the partial render html tagcan apply style setting defined in .css file.

i think this should a bug. coz in web design, we usually use a method like <%=Util.GetApplicationPath%> to get a real web app path against a IIS Website, so that we can deploy our web app under awebsite or avirtual directory without changing any resource (e.g css/js/gif/jpg/etc.) path.-->

you should try to use the "~" character in your path

for example:
<img src="http://pics.10026.com/?src=~/Images/myimage.gif" runat="server"> this would start the path at your application root for the website or virtual directory then take you to the images folder then of course display your image...


the "~" character is very useful, but it has a restriction when use. coz it always renderrelative web application root path based onthe same web server. in web farm condition, we usually require absolute resource path. further, the absolute resource path maybe dynamically generated according some business logic, so this is why we need a static method like <%=Util.GetApplicationPath()%> to getruntime absolute resource path.


change the <%=Util.GetApplicationPath()%> to<%# Util.GetApplicationPath()%> and I think you will get your desired results...I ran into the same issue with a project I was working ...

No comments:

Post a Comment