Gridview Row textbox.Attributes.Add("onblur",

Posted on 2007-10-15
Last Modified: 2012-08-13
Given the below code in an gridview RowCreated event:
        if (e.Row.RowType == DataControlRowType.DataRow)
            TextBox textbox =

How can "alert('OnBlur!' above be replaced by javascript focus() of  (TextBox)e.Row.Cells[4].FindControl("txtBox2")? How can txtBox2 be invoked in javascript?
Question by:ksfok
    LVL 16

    Expert Comment

    I guess you're trying to focus the next row onblur

    If textbox's id are ordered as txtBox1, txtBox2, .. , txtBoxN

    textbox.Attributes.Add("onblur", "document.getElementById('txtBox'");
    LVL 16

    Expert Comment

    More clean code (group by parentheses)

    textbox.Attributes.Add("onblur", "document.getElementById('txtBox'+(");

    Author Comment

    Please remember here we are not dealing with a plain web page. Our commotion is taking place in a row of textboxes in a gridview's Row Created event. Please help. Thanks.
    LVL 16

    Accepted Solution

    Yes, we're not dealing with a plain web page, but we're providing a plain web page with javascript embed with all textboxes in a table (GridView). Use my code at your original posted code.

    The script is not fired at server, but at client after a textbox's focus was leaved.
    Or .. It might be I dont understand your question.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
    In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    759 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

    10 Experts available now in Live!

    Get 1:1 Help Now