How can i pass a parrameter from Asp to jquery?
i have a Listview with dynamics rows that read them from database. now i want when mouse is going on one of it's data perform special work on it.(like bellow code)
$(document).ready(function(){
$("*").mouseover(function () {/开发者_如何学JAVA/this line
$("*").animate({ //this line
width: "120px",
height:"120px",
}, 150);
});
my problem is that what i must write instead *
,because their ids a changing dynamically and i can't user from class
.
how can i do that?
Although it's not a direct answer to your question but in order to get the client id of any asp.net server control you could simple use:
var controlId = '<%= txtBox1.ClientID %>' //where txtBox1 is the actual id specified in
markup
similarly, you can pass the client id of any control to javascript function, e.g.
function animate(id) {
$('$' + id).animate({ //this line
width: "120px",
height:"120px",
}, 150);
}
//and to call this animate function from aspx markup
.... onfocus='animate('<%=ControlId.ClientID%>');
set ClientIDMode of your control to static
like ClientIDMode="Static"
and give your control a ID that you remember, then you can easily get the value at the client side
say e.g.
<asp:TextBox ID="myTxtBox" ClientIDMode="static" Text='<%#Eval("Name") %>' runat="server"></asp:TextBox>
in JS
var txt = $("#myTxTBox").text();
here is a good post http://www.shubho.net/2011/01/understanding-clientidmodepredictable.html
精彩评论