Setting control focus programatically on an aspx page

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Todd

    Setting control focus programatically on an aspx page

    Does anyone know how to set the focus to a control programatically in my code
    for an asp.net app?

    --

    Thanks in advance,

    Todd
  • Xavier Pacheco

    #2
    Re: Setting control focus programatically on an aspx page

    You basically have to use client side java script code. See the
    article:




    --
    Xavier Pacheco
    Xapware Technologies Inc

    manage your projects: www.xapware.com/ActiveFocus.htm
    the blog: www.xavierpacheco.com/xlog
    the book: https://www.amazon.com/exec/obidos/A...vierpacheco-20

    Comment

    • Cor Ligthert

      #3
      Re: Setting control focus programatically on an aspx page

      Todd

      I do it this way (I cannot do it from "code behind" because that it has to
      be runned as last)

      <INPUT tabindex="1" id="fieldid" type="text" size="27">
      fieldid is just the name of the control

      //This should be the last rows in your html aspx file

      <script language="JavaS cript">
      document.all("f ieldid").focus( );
      </script>
      </HTML>

      I hope this helps a little bit?

      Cor


      "Todd" <Todd@discussio ns.microsoft.co m>
      [color=blue]
      > Does anyone know how to set the focus to a control programatically in my
      > code
      > for an asp.net app?
      >
      > --
      >
      > Thanks in advance,
      >
      > Todd[/color]


      Comment

      • Cor Ligthert

        #4
        Re: Setting control focus programatically on an aspx page

        Todd

        I do it this way (I cannot do it from "code behind" because that it has to
        be runned as last)

        <INPUT tabindex="1" id="fieldid" type="text" size="27">
        fieldid is just the name of the control

        //This should be the last rows in your html aspx file

        <script language="JavaS cript">
        document.all("f ieldid").focus( );
        </script>
        </HTML>

        I hope this helps a little bit?

        Cor


        "Todd" <Todd@discussio ns.microsoft.co m>
        [color=blue]
        > Does anyone know how to set the focus to a control programatically in my
        > code
        > for an asp.net app?
        >
        > --
        >
        > Thanks in advance,
        >
        > Todd[/color]


        Comment

        Working...