If TextBox1.Text = "" Then
Response.Write("<script>window.alert('用户名不能为空!')</script>")
ElseIf TextBox2.Text = "" Then
Response.Write("<script>window.alert('密码不能为空!')</script>")
Else
Try
Dim ssconstr As String = "server=192.168.0.1;database=cszjc-website;user id=maverickps;password=zsjyc;"
Dim ssqlstr As String = "select * from login where username='" + TextBox1.Text + "' and password='" + TextBox2.Text + "'"
Dim ssobjconn As New SqlConnection(ssconstr)
Dim ss As New SqlCommand(ssqlstr, ssobjconn)
ssobjconn.Open()
Dim mydr As SqlDataReader = ss.ExecuteReader() If mydr.Read Then
Response.Redirect("Sd-login/login.aspx")
Else
Response.Redirect("error.htm")
End If
Catch ex As Exception
Response.Write("<script>window.alert('登陆失败!')</script>")
End Try
End If/////////////////////////////////////////////
Dim xy As String
xy = DropDownList1.SelectedValue.ToString()
Dim user, pass As String
user = TextBox3.Text
pass = TextBox4.Text If user = "" Then
Response.Write("<script>window.alert('用户名不能为空!')</script>")
ElseIf pass = "" Then
Response.Write("<script>window.alert('密码不能为空!')<script>")
Else
Try
Dim constr As String = "server=192.168.0.1;database=netconfer;user id=maverickps;password=zsjyc;"
Dim sqlstr As String = "select * from xyuser where name='" + user + "' and pass='" + pass + "' and status='" + xy + "'"
Dim objconn As New SqlConnection(constr)
Dim ss As New SqlCommand(sqlstr, objconn)
objconn.Open()
Dim mydr As SqlDataReader = ss.ExecuteReader() If mydr.Read Then
Response.Redirect("careersystem/departsystem/depatsys.aspx?xy=" & DropDownList1.SelectedValue.ToString())
Else
Response.Write("error-1.htm")
End If
Catch ex As Exception
Response.Write("<script>window.alert('登陆失败!')</script>")
End Try
End If第一段代码中对密码可以进行控制判断,textbox2.text = ""
但第二段代码中对密码就不能进行空值判断了textbox4.txt = ""
还有,我想对DropDownList1.SelectedValue.ToString()的值进行判断,要求用户必须进行选择
下面是dropdownlist1的代码
<asp:dropdownlist id="dropdownlist1" runat="server">
<asp:listitem value="" selected="true"></asp:listitem>
<asp:listitem value="1">北京</asp:listitem>
<asp:listitem value="2">上海</asp:listitem>
</asp:dropdownlist>就是对value值进行判断,谢谢各位。
Response.Write("<script>window.alert('用户名不能为空!')</script>")
ElseIf TextBox2.Text = "" Then
Response.Write("<script>window.alert('密码不能为空!')</script>")
Else
Try
Dim ssconstr As String = "server=192.168.0.1;database=cszjc-website;user id=maverickps;password=zsjyc;"
Dim ssqlstr As String = "select * from login where username='" + TextBox1.Text + "' and password='" + TextBox2.Text + "'"
Dim ssobjconn As New SqlConnection(ssconstr)
Dim ss As New SqlCommand(ssqlstr, ssobjconn)
ssobjconn.Open()
Dim mydr As SqlDataReader = ss.ExecuteReader() If mydr.Read Then
Response.Redirect("Sd-login/login.aspx")
Else
Response.Redirect("error.htm")
End If
Catch ex As Exception
Response.Write("<script>window.alert('登陆失败!')</script>")
End Try
End If/////////////////////////////////////////////
Dim xy As String
xy = DropDownList1.SelectedValue.ToString()
Dim user, pass As String
user = TextBox3.Text
pass = TextBox4.Text If user = "" Then
Response.Write("<script>window.alert('用户名不能为空!')</script>")
ElseIf pass = "" Then
Response.Write("<script>window.alert('密码不能为空!')<script>")
Else
Try
Dim constr As String = "server=192.168.0.1;database=netconfer;user id=maverickps;password=zsjyc;"
Dim sqlstr As String = "select * from xyuser where name='" + user + "' and pass='" + pass + "' and status='" + xy + "'"
Dim objconn As New SqlConnection(constr)
Dim ss As New SqlCommand(sqlstr, objconn)
objconn.Open()
Dim mydr As SqlDataReader = ss.ExecuteReader() If mydr.Read Then
Response.Redirect("careersystem/departsystem/depatsys.aspx?xy=" & DropDownList1.SelectedValue.ToString())
Else
Response.Write("error-1.htm")
End If
Catch ex As Exception
Response.Write("<script>window.alert('登陆失败!')</script>")
End Try
End If第一段代码中对密码可以进行控制判断,textbox2.text = ""
但第二段代码中对密码就不能进行空值判断了textbox4.txt = ""
还有,我想对DropDownList1.SelectedValue.ToString()的值进行判断,要求用户必须进行选择
下面是dropdownlist1的代码
<asp:dropdownlist id="dropdownlist1" runat="server">
<asp:listitem value="" selected="true"></asp:listitem>
<asp:listitem value="1">北京</asp:listitem>
<asp:listitem value="2">上海</asp:listitem>
</asp:dropdownlist>就是对value值进行判断,谢谢各位。
解决方案 »
- jQuery失效,急急急急急急急急急急急!!!!!!!!
- 求正则表达式字符串补0
- asp.net mvc 路由设置
- 开发中的数据库设计问题
- update voter set time=#2007/04/28# 14:04:44# where id=1 错在哪了 请大哥指点
- 问个很菜的问题.关于DataGrid模板列里的Checkbox的控制
- web.config配置问题!?
- asp.net页面可以自定义匿名用户吗?
- 请大家来看看我的这段制作缩略图代码是哪错了~~~
- 哪位大虾有aspnetmenu的正式版?
- document.forms[0]什么意思
- 急,在线等,关于CheckBoxList控件
Response.Write("<script>window.alert('用户名不能为空!')</script>")
return
ElseIf TextBox2.Text = "" Then
Response.Write("<script>window.alert('密码不能为空!')</script>")
return
Else
if DropDownList1.SelectedText.ToString()="请选择城市" then
Response.Write("<script>window.alert('请选择城市!')</script>")
return
DropDownList1.Items.Insert(0,"请选择城市") //为下拉框添加第一项~
If TextBox3.Text = "" Then
Response.Write("<script>window.alert('用户名不能为空!')</script>")
return
ElseIf TextBox4.Text = "" Then
Response.Write("<script>window.alert('密码不能为空!')</script>")
return
Else
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim user, pass As String
user = TextBox3.Text
pass = TextBox4.Text Dim xy As String
xy = DropDownList1.SelectedValue.ToString() If user= "" Then
Response.Write("<script>window.alert('用户名不能为空!')</script>")
Return
ElseIf pass = "" Then
Response.Write("<script>window.alert('密码不能为空!')<script>")
Return
ElseIf DropDownList1.SelectedValue.ToString() = "请选择" Then
Response.Write("<script>window.alert('不能为空!')<script>")
Return
Else
Try
Dim constr As String = "server=192.168.0.1;database=netconfer;user id=maverickps;password=zsjyc;"
Dim sqlstr As String = "select * from xyuser where name='" + user + "' and pass='" + pass + "' and status='" + xy + "'"
Dim objconn As New SqlConnection(constr)
Dim ss As New SqlCommand(sqlstr, objconn)
objconn.Open()
Dim mydr As SqlDataReader = ss.ExecuteReader() If mydr.Read Then
Response.Redirect("careersystem/departsystem/depatsys.aspx?xy=" & DropDownList1.SelectedValue.ToString())
Else
Response.Write("error-1.htm")
End If
Catch ex As Exception
Response.Write("<script>window.alert('登陆失败!')</script>")
End Try
End If
End Sub