JQuery Alert Popup Blank Using GridView Textbox?

Posted on 2012-08-16
Last Modified: 2012-09-05
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!


<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());

[body, form]

 <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" />
            <asp:TemplateField HeaderText="Data">
                    <asp:TextBox ID="txtData" runat="server" Text="" style=" height: 44px; width: 100px"></asp:TextBox>
Question by:pointeman
    LVL 13

    Accepted Solution

    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:
        $("#GridView1_ctl02_txtData").blur(function (event) {            
            var data = $.trim($(this).text());

    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.

    Author Comment

    Oops, typo error. I know to always use the $(document).ready() as you pointed out. Good eyes.

    Author Closing Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Javascript: Crash Course

    Javascript is not only emerging as the most important language to know, it's flexibility is unique. With Javascript being deployed on the web, mobile and even the desktop this is the one language that all technologists need to know.

    To Start with ... One of the most annoying things in developing web pages is handling the 'Enter Key' for form submission. The 'Enter Key' makes form submission so easy that the user always tend to use it. The easiest and the most intuitive way …
    Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now