0

我有一个gridview,我试图选择在gridview 的特定行上单击的链接按钮的值。下面是我的代码,由于在gridview中选择不正确的链接按钮而出错。请帮我解决这个问题。

在页面加载时这是错误

ASP.Test_aspx 不包含“lnkview”的定义,并且找不到接受“ASP.createsegment_aspx”类型的第一个参数的扩展方法“lnkview”(您是否缺少 using 指令或程序集引用?)

功能:

 $(document).ready(function() {

             if($('#<%=this.lnkview.ClientID %>').length){
              $('#this.lnkview').click(function(event) {
                    event.preventDefault();
                    $('#plnClone').dialog({
                        modal: true,
                        width: 550,
                        height: 250,
                        open: function(type, data) {
                            $(this).parent().appendTo("form");
                        }
                    });
                });
            }

            $('#CancelClone').click(function(event) {
                event.preventDefault();
                $('#plnClone').dialog('close');
            });
            //
            if ($('#hfdCloneOffer').val() == "DUPLICATE") {
                $('#plnClone').dialog({
                    modal: true,
                    width: 550,
                    height: 250,
                    open: function(type, data) {
                        $(this).parent().appendTo("form");
                    }
                });
                //
                // Scroll to Page Top
                $('html, body').animate({ scrollTop: '0px' }, 800);
            }
4

2 回答 2

1

The second line of your code appears to be missing the server tags.

$('#this.lnkview') 

Should become

$('#<%=this.lnkview.ClientID %>')

EDIT Looking at your markup, I don't think you'll be able to do a lnkView.ClientID on it outside of the grid row. Suggest you use put a class on your linkbutton and use it as a selector instead.

MORE EDIT Something like this should work

<asp:LinkButton ID="lnkView" runat="server" Text="View" CausesValidation="false" CssClass="lnkViewClass">

          $('.lnkViewClass').click(function(event) {
                event.preventDefault();
                $('#plnClone').dialog({
                    modal: true,
                    width: 550,
                    height: 250,
                    open: function(type, data) {
                        $(this).parent().appendTo("form");
                    }
                });
            });
        }
于 2013-05-14T09:27:07.983 回答
0

Are you sure that you have element with id 'lnkview' in your aspx code? You are calling this here '#<%=this.lnkview.ClientID %>'

于 2013-05-14T09:26:33.043 回答