2011-09-17 45 views
3

我有一個列表視圖與動態行從數據庫中讀取它們。 現在我當鼠標在其上的數據的一個會想對它進行特別的工作。(像婁代碼)如何將參數從Asp傳遞給jquery?

 $(document).ready(function(){ 
    $("*").mouseover(function() {//this line 
     $("*").animate({    //this line 
      width: "120px", 
      height:"120px", 

     }, 150); 
}); 

我的問題是什麼,我必須寫,而不是*,因爲他們的ID的動態,我改變不能從class用戶。 我該怎麼做?你控制staticClientIDMode="Static",給你的控制,你還記得一個ID的

+0

這個動畫功能,你可以嘗試使用活()API 。 http://api.jquery.com/live/ –

回答

0

雖然這不是直接回答你的問題,但爲了得到任何asp.net服務器控件的客戶端ID你可以簡單的使用:

var controlId = '<%= txtBox1.ClientID %>' //where txtBox1 is the actual id specified in markup

同樣,您可以將任何控件的客戶端ID傳遞給javascript函數,例如jQuery的的

function animate(id) { 
$('$' + id).animate({    //this line 
      width: "120px", 
      height:"120px", 

     }, 150); 
} 

//如果行生成的ID都印有圖案或有一個共同的類來調用從ASPX標記

.... onfocus='animate('<%=ControlId.ClientID%>');