Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles submit.Click
If (txtuid.Text = "isol" & txtpwd = "a") Then
Session("uid") = txtuid.Text
Response.Redirect("IPDbilling.aspx")
Return
Else
lblmsg.text = "invalide details"
lblmsg.ForeColor = System.Drawing.Color.Red
Response.Redirect("login.aspx")
End If
End Sub
2 に答える
1
Andの代わりに使ってみてください&。
If (txtuid.Text = "isol" And txtpwd = "a") Then
また、txtpwdが の場合、 ではなくTextBoxを使用する必要があります。txtpwd.Texttxtpwd
&VB.NET では、文字列の連結演算子です。
Dim val1 As String = "Hello"
Dim val2 As String = " World!"
Dim val3 As String = val1 & val2
val3 は「Hello World!」と等しくなります。
AndAlsoを使用して短絡評価を実行することもできます。
If (txtuid.Text = "isol" AndAlso txtpwd = "a") Then
この場合、txtuid.Textが "isol" と等しくない場合、2 番目の部分 ( txtpwd = "a") は評価されません。
于 2013-09-11T07:02:35.780 に答える