2
有沒有辦法獲得分配給javascript或代碼隱藏的控件的資源鍵?說我有此標籤的網頁上:從javascript或代碼隱藏獲取資源對象
<asp:Label runat="server" ID="Label1" meta:resourcekey="Label1Resource1" />
然後在代碼隱藏我補充一點:
Label1.Attributes.Add("onclick", "InspectMe(this);");
最後的JavaScript:
<script language="javascript" type="text/javascript">
function InspectMe(ctl) {
// how do I get the resourcekey?
alert(ctl);
}
</script>
於是就點擊JS有控制,但有什麼方法可以讀取資源密鑰?請注意,我不想要實際的資源字符串(文本),我希望它返回「Label1Resource1」。
或者,代碼隱藏解決方案也可以。我的第一個直覺是轉向GetLocalResourceObject,但我看不到從控件獲取鍵名的方法。