none
Event Handler executes twice RRS feed

  • Question

  • i am writing a web application.

    when the send button on one of my forms is clicked, its event handler executes twices, for reasons i don't know; thereby returning the same data twice.

    can anyone help me. the event handler is below incase it may be useful:

    Protected Sub btnSend_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSend.Click
        'dimension array to hold results
        Dim UserArray As User() = New User() {}
    
        btnSend.Enabled = False
        'Label1.Text = ""
    
        'if no departmentId is entered, set d value to zero to evade error. else parse the value entered.
        Dim deptId As Integer
        If txtDeptID.Text <> "" Then
          deptId = Integer.Parse(txtDeptID.Text)
        Else
          deptId = 0
        End If
    
        Try
          UserArray = myRequests.GetUsers(txtUserID.Text, txtFName.Text, txtLName.Text, txtOName.Text, deptId)
        Catch ex As Exception
          MsgBox(ex.Message)
        End Try
    
        'check if there are any registered users.
        If UserArray Is Nothing Then
          'Label1.Text = "There are no results to show"
          btnSend.Enabled = True
          Exit Sub
        End If
    
        'clear gridview to add new items
        'tableUsers.Rows.Clear()
    
        'retrieve the properties of the current user and add to table
        For Each eachUser In UserArray
          'declare a new tableRow for current user being retrieved
          Dim ro As New TableRow
    
          For i As Integer = 0 To 3
            Dim celCol As TableCell = New TableCell
    
            Select Case i
              Case 0
                celCol.Text = eachUser.userID
              Case 1
                celCol.Text = eachUser.firstName
              Case 2
                celCol.Text = eachUser.lastName
              Case 3
                celCol.Text = eachUser.otherName
            End Select
            'add current cell to the row collection.
            ro.Cells.Add(celCol)
          Next
          'finally, add the row to the table
          tableUsers.Rows.Add(ro)
        Next
    
        btnSend.Enabled = True
      End Sub

    Wednesday, July 28, 2010 12:28 PM

Answers

  • Hi,

      Thanks for your post. The code seems fine to me. Could you debug into it to see how the whole logic proceeds?


    Please mark the right answer at right time.
    Thanks,
    Sam
    • Edited by SamAgain Tuesday, August 3, 2010 9:34 AM refine
    • Marked as answer by SamAgain Thursday, August 5, 2010 7:05 AM
    Tuesday, August 3, 2010 9:34 AM

All replies

  • Hi,

      Thanks for your post. The code seems fine to me. Could you debug into it to see how the whole logic proceeds?


    Please mark the right answer at right time.
    Thanks,
    Sam
    • Edited by SamAgain Tuesday, August 3, 2010 9:34 AM refine
    • Marked as answer by SamAgain Thursday, August 5, 2010 7:05 AM
    Tuesday, August 3, 2010 9:34 AM
  • We temporarily mark a reply, please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as Answer" if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    Please mark the right answer at right time.
    Thanks,
    Sam
    Thursday, August 5, 2010 7:05 AM