How can i use a js variable in mouseOver event?
Here is my code:
<script type="text/javascript">
window.String1 = <%=GetLocalResourceStringEscaped("String1")%>;
window.String2 = <%=GetLocalResourceStringEscaped("String2")%开发者_运维知识库>;
</script>
<label runat="server" id="labelWeight" onmouseout="HelpOut(this);" onmouseover="Help(this,window.String1,window.String2);">
<asp:Localize ID="LocPWeight" runat="server" meta:Resourcekey="ProductWeightInGrams"
Text="Product Weight in Grams"></asp:Localize>
</label>
and it looks like it doesn't work this way :).
Thanks. !
Try this:
onmouseover = 'Help(this,<%=GetLocalResourceStringEscaped("String1")%>, <%=GetLocalResourceStringEscaped("String2")%>);';
I figure it out i needed qoutes:
window.String1 = <%=GetLocalResourceStringEscaped("String1")%>;
has to be
window.String1 = '<%=GetLocalResourceStringEscaped("String1")%>';
Your soulutions didn't work. If the label contains a runat="server" attribute "<%= %>" tags are not allowed. That's why i didn't use it in the first place, but i forgot to mention it. Sorry for that.
Thanks you for your answers!
Try this:
onmouseover='function(){Help(this,<%= GetLocalResourceStringEscaped("String1") %>,<%= GetLocalResourceStringEscaped("String2") %>);}'
精彩评论