1

这是ASP.NET 如何将容器值作为 javascript 参数传递的后续问题

Darin Dimitrov使用jQuery提供了他的答案, 但由于某种原因,我无法选择我想要的网格行。

这是用于选择行的jQuery。

$(function() {
    $('#_TrustGrid input[name^=trustDocIDTextBox]').each(function(index) {
        $(this).click(function() {
            alert('Hello world = ' + index);
            setGridInEditMode(index);
        });
    });
});

这是实际的输出 HTML 标记。

<input 
    id="_TrustGrid_ctl16_ctl05_ctl00_trustDocIDTextBox" 
    type="text" value="198327493" 
    name="_TrustGrid$ctl16$ctl05$ctl00$trustDocIDTextBox"/>

我今晚才开始使用 jQuery,并浏览
了官方的jQuery Selectors文档,但没有成功。



我在这里错过了什么吗?

4

3 回答 3

0

我做了什么来保存我在 .aspx 页面中使用的控件的完整 ID:

<input type="hidden" 
       id="SubcontractorDropDownID" 
       value="<%= SubcontractorDropDown.ClientID %>" />

然后,您可以获取 id 的值,然后在查询中使用它来了解要使用的行。

于 2009-10-20T02:32:08.963 回答
0

乍一看,我认为您只想要一个 '$' 而不是 '^' 并且您应该在选择器中定位 ID 而不是 NAME?

$(function() {
    $('#_TrustGrid input[id$=trustDocIDTextBox]').each(function(index) {
        $(this).click(function() {
            alert('Hello world = ' + index);
            setGridInEditMode(index);
        });
    });
});
于 2009-10-20T02:35:53.170 回答
0

我不知道为什么选择通过#_TrustGrid不起作用。:input通过指定如下所示,我能够解决该问题。

    $(function() {
        //$('#_TrustGrid input[id$=trustDocIDTextBox]').each(function(index) {
        $(':input[id$=trustDocIDTextBox]').each(function(index) {
            $(this).click(function() {
                alert('Hello world = ' + index);
                setGridInEditMode(index);
            });
        });
    });
于 2009-10-20T03:30:11.453 回答