Set focus and postback issue

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

    #1

    Set focus and postback issue

    Howdy all.
    Using visual web developer (VB) on xp pro box.

    My problem with with a web form that on accessing the calendar control
    causes a postback that moves the cursor back to the txtFirstName
    field.

    Form uses the Page_LoadComple te in order to access the last employeeID
    # in a dataview which is populated by an sqlDataObject querying an SQL
    Server dbs.

    Am using javascript to cause the cursor to move to the txtFirstName
    field after updating the txtEmployeeID field. Reason is that for me no
    other method would advance the cursor to the txtFirstName field.

    However, after tabbing through the first, last and hire fields to
    access the calendar button - using an image button but same issue
    occurs with regular button - on clicking the image button to display
    the calendar object, you see the cursor move to the txtFirstName
    field. Then after selecting the appropriate date, the cursor moves to
    the department dropdown (unbound). No further movement is noticed as
    I'm just tabbing through the fields to the Submit New Employee button.
    All the dropdowns are set to autopostback = false.

    Would greatly appreciate your suggestions/comments on how to move the
    cursor to the txtFirstName field and not have it move back to this
    field on a postback.

    Thank you,

    Rey




    Protected Sub Page_LoadComple te(ByVal sender As Object, ByVal e As
    System.EventArg s) Handles Me.LoadComplete
    ' obtaining last employeid after page loaded since I'm using the
    sqldata obj

    'If Not IsPostBack Then
    Dim intLastID As Integer
    'Dim test As Control = FindControl("tx tFirstName") ' trying
    to set focus

    intLastID =
    Convert.ToInt32 (grdLastEmploye e.Rows.Item(0). Cells.Item(0).T ext)

    txtEmployeeID.T ext = (intLastID + 1).ToString

    ' txtFirstName.Fo cus() ' does not work - results in cursor
    being in front of the new employee #


    'End If

    End Sub

    <script language="JavaS cript">
    function setFocus()
    {
    Form1.txtFirstN ame.focus();

    }
    </script>

    <body leftmargin="0" topmargin="0" style="text-align: center"
    onload="setFocu s();" ><form id="Form1" runat="server" >

  • Rey

    #2
    Re: Set focus and postback issue

    Forgot to mention that form in question is a multivew form.
    Thanks,
    Rey

    Comment

    • Rey

      #3
      Re: Set focus and postback issue

      On Mar 20, 8:52 am, "Rey" <reycoll...@cox .netwrote:
      Forgot to mention that form in question is a multivew form.
      Thanks,
      Rey
      Disregard - my error & frustration. Found that I had the focus set to
      the txtEmployeeID field after the multivew form was selected. This
      would then cause the cursor to move back to the field.

      Thanks

      Comment

      Working...