7 Replies Latest reply on Dec 16, 2016 8:52 PM by Sabir Valappil Thattath

    using the focus event

    Brian Smith

      When I have static controls on my webpage I am able to set the focus to a control using the following:

       

             @Html.TextBoxFor(m => m.UserName, new{  id = "usertxtId",

                                                    autofocus = "autofocus",

                                                     Style = "background-color:gray;color:black;font-size:2em;width:100%"

                                                    })

       

       

      <script>

          $(function ()

          {

              $("#usertxtId").focus();

              $('#usertxtId').get(0).focus();

          });

      </script>

         

      However when I am dynamically creating controls This is not working ... at one point I had it so the control would get highlighted, but the form would not allow me to enter data... I had to remove several conflicting libraries (jquery mobile) and now this no longer works.

       

      For my dynamic controls I am using the same code model as the static (see above) ... but it is not working...