0
我有這個C#用戶控件類:爲什麼java腳本不能訪問這個asp.net var?
public partial class UserControls_JsTop : System.Web.UI.UserControl
{
public static string sidebarBannerUrl = getSideBarBannerImgUrl();
protected void Page_Load(object sender, EventArgs e)
{
}
public static string getSideBarBannerImgUrl(){
DataClassesDataContext db = new DataClassesDataContext();
var imgUrl = (from b in db.Banners
where b.Position.Equals(EBannersPosition.siderbar.ToString())
select b).FirstOrDefault();
if (imgUrl != null)
return imgUrl.Path;
return String.Empty;
}
}
我嘗試存取權限的JS腳本靜止無功:
負荷在這裏:
<script type="text/javascript">
var categoryParam = '<%# CQueryStringParameters.CATEGORY %>';
var subcategory1Param = '<%# CQueryStringParameters.SUBCATEGORY1_ID %>';
var subcategory2Param = '<%# CQueryStringParameters.SUBCATEGORY2_ID %>';
var imgUrl = '<%# UserControls_JsTop.sidebarBannerUrl %>';
</script>
,並在這裏使用它(imgUrl的):
<script type="text/javascript" language="javascript">
$(function() {
$(document.body).sidebar({
size: "30px", // can be anything in pixels
length: "270px", // can be anything in pixels
margin: "300px", // can be anything in pixels
position: "left", // left/bottom/right/top
fadding: "0.8", // 0.1 to 1.0
img: imgUrl,
openURL: "www.twitter.com/amitspatil"
});
});
</script>
我不明白它爲什麼是空的。 請相信我,在這種情況下,DB中有記錄。
我想加載VAR時,有一些JS問題...
你知道在哪裏?
感謝
你有一個XSS洞。 – SLaks 2010-12-02 20:29:04