我有我的的.aspx的代碼隱藏以下屬性:字符串是未定義
protected string CurrentProductView
{
get
{
string viewName = string.Empty;
viewName = Enum.GetName(typeof(ProductView), currentProdView);
return viewName;
}
}
在我的.aspx我有一些JavaScript試圖引用這個字符串:
$(document).ready(function()
{
var action = <%=CurrentProductView %>
$("#recommendations").load("recommendationsHandler.ashx?action=" + action + "item&csid=" + csid + "&productID=" + productID, function()
{
$("#recommendationsView").show();
});
});
但由於某種原因,我得到「項目未定義」。
當我調試這個,我肯定看到一個字符串回來viewName。那麼爲什麼它會抱怨如果一個字符串回來?!?!
你能分享與Javascript交互的代碼? – 2010-06-28 15:08:55
你不應該在字符串周圍有引號嗎? 'var action =「<%= CurrentProductView%>」;' – 2010-06-28 15:09:16
不,它引用了服務器端屬性。 – PositiveGuy 2010-06-28 15:10:04