locked
tab index changed event for a textbox RRS feed

  • Question

  • User109943568 posted

    hi All,

       I have a textbox which is in formview control and i need to add a tab index changed event fot it. (to bring an alert box on tab press for that control).

    Please help me with that .

    Thursday, June 5, 2014 12:18 AM

Answers

  • User-663458986 posted

    Below script will find the textbox inside the formview during control rendering and bind a script with that textbox.

    please replace your textbox ID with "txtScript"

     protected void Formview1_ItemCreated(object sender, EventArgs e)
        {
            TextBox _txt = (TextBox)Formview1.FindControl("txtScript");
            if (_txt != null)
            {
                string _Script = @"$('#" + _txt.ClientID + "').keydown(function(event){" +
                                    " if(event.which == 9){alert('Tab Pressed');}" +
                                "});";
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "checkLostFocus", _Script, true);
            }
        }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 5, 2014 12:56 AM

All replies

  • User-663458986 posted

    Below script will find the textbox inside the formview during control rendering and bind a script with that textbox.

    please replace your textbox ID with "txtScript"

     protected void Formview1_ItemCreated(object sender, EventArgs e)
        {
            TextBox _txt = (TextBox)Formview1.FindControl("txtScript");
            if (_txt != null)
            {
                string _Script = @"$('#" + _txt.ClientID + "').keydown(function(event){" +
                                    " if(event.which == 9){alert('Tab Pressed');}" +
                                "});";
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "checkLostFocus", _Script, true);
            }
        }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 5, 2014 12:56 AM
  • User109943568 posted

    Hi, you answer helped me, thank you.

    it worked with firmview load event instead.

    Thursday, June 5, 2014 1:16 AM