• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 715
  • Last Modified:

JQuery Alert Popup Blank Using GridView Textbox?

Keep getting a blank Alert Popup with this code. The .blur 'fires', but no data shows in alert popup.  Note: GridView1_ctl02_txtData is found in IE9 'view source', help!

[head]

<script type="text/javascript" src="/scripts/jquery-1.8.0.js"></script>
<script type="text/javascript">
      $("#GridView1_ctl02_txtData").blur(function (event) {            
             var data = $.trim($(this).closest("tr").find("#GridView1_ctl02_txtData").text());
             alert(data);
       });
</script>

[body, form]

 <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" />
        <Columns>
            <asp:TemplateField HeaderText="Data">
                <ItemTemplate>
                    <asp:TextBox ID="txtData" runat="server" Text="" style=" height: 44px; width: 100px"></asp:TextBox>
                </ItemTemplate>            
        </Columns>
    </asp:GridView>
0
pointeman
Asked:
pointeman
  • 2
1 Solution
 
JonNormanCommented:
I think that you should surround the code in $(document).ready() (unless you are in an asp update panel). Also I can't see why you are going up the dom and then back down to the object that you already have. What happens when you do the following code:
$(document).ready(function(){
    $("#GridView1_ctl02_txtData").blur(function (event) {            
        var data = $.trim($(this).text());
        alert(data);
    });
});

Open in new window

This should alert the text of the textarea on blur.

If you need any more help then please let us know why you want to go up the dom and back down and post the complete html as seen by view source in the browser.
0
 
pointemanAuthor Commented:
Oops, typo error. I know to always use the $(document).ready() as you pointed out. Good eyes.
0
 
pointemanAuthor Commented:
Thx
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now