I'm developing a login page for my web-based(asp.net)visual basics application, I want the user name entered on the login page be visible on a label on the redirected form. I page redirect depeding on various occations, for example if the entered user name is for a system administrator I want a redirect to the admin page. and to do so if the user is a Picker, Stock Controller, and loader etc

So now, my problem is when I put an IF statement to my codes, but without an if statement i can redirect to only one page, so if I put an if statement the codes are not processed by the system.

I need someone who can assist with correcting the codes so that they do as I need, thanks in advance

`

 Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
        If TextBox3.Text = "Administrator" Then
            Response.Redirect("AddUser.aspx?val=" + TextBox1.Text)
        ElseIf TextBox3.Text = "Receiver" Then
            Response.Redirect("Offload.aspx?val=" + TextBox1.Text)
        ElseIf TextBox3.Text = "Stock Controller" Then
            Response.Redirect("Stock Rotation.aspx?val=" + TextBox1.Text)
        ElseIf TextBox3.Text = "Picker" Then
            Response.Redirect("Pick Order.aspx?val=" + TextBox1.Text)
        ElseIf TextBox3.Text = "Loader" Then
            Response.Redirect("load.aspx?val=" + TextBox1.Text)
        End If
    End SubInline Code Example Here

`

How are the values for TextBox1 and TextBox3 getting into the textboxes? I would like to see more explanitory names, describing how you are using these controls. TextBox3 seems to be user type, but what is TextBox1? Are you sure that those are the exact text appearing in TextBox3? Put a break-point on the first line and then see what text is actually in that TextBox. I also would tend to use a Select block instead of an If as that will only need to query the Textbox once, not onces for each condition.

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
    Select Case TextBox3.Text
        Case "Administrator"
            Response.Redirect("AddUser.aspx?val=" + TextBox1.Text)
        Case "Receiver"
            Response.Redirect("Offload.aspx?val=" + TextBox1.Text)
        Case "Stock Controller"
            Response.Redirect("Stock Rotation.aspx?val=" + TextBox1.Text)
        Case "Picker"
            Response.Redirect("Pick Order.aspx?val=" + TextBox1.Text)
        Case "Loader"
            Response.Redirect("load.aspx?val=" + TextBox1.Text)
        Case Else
            ' What do you want to happen if everything misses?
            ' Present an error page and/or add a line to the error log?
            ' This can help with debugging.
    End Select
End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.