2009-11-10 72 views
0

我有Telerik網格控件,那裏有一個編輯控件,比如更新和取消按鈕等等。找到動態控制

當我編輯圖像點擊時,編輯控件會自動顯示,沒有用於調用控件的手動編碼。因此,我的問題是我必須驗證輸入控件,當我更新按鈕點擊。這些控件是動態創建的。所以我使用它的客戶端id值來使其運行。但我做不到。我使用了下面的代碼。

$('#RadGrid1_ctl00_ctl05_btnUpdate').click(function() { 
     alert("hai..Update Button"); 
     //Here I have to validate input controls 
    }); 

-Thanks

+0

我不知道我理解你的問題是什麼/你想要什麼 – jitter 2009-11-10 12:12:57

回答

3

可以使用partial attribute selector找到一個元素,其id屬性包含您分配給該控件的ID:

$('[id$=btnUpdate]').click(funciton() { 
    alert('hai ... Update Button'); 
}); 

這將綁定到任何元素,其id屬性以'btnUpdate'結尾。

如果您的網格控件是動態的,您可能需要使用live() event binder像這樣:

$('[id$=btnUpdate]').live('click', funciton() { 
    alert('hai ... Update Button'); 
}); 
+0

嗨,我試過上面是不能正常工作。是否有其他方式來做到這一點...... – user182401 2009-11-11 09:47:13

+0

如果你的網格是動態的,你可能想嘗試使用'live()'。我已經更新了我的答案。 – brianpeiris 2009-11-16 01:36:48