主题:[讨论]怎么老提示“无效字符”
我的两个文件的代码如下,怎么会老提示无效字符呢?
index.aspx
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="index.aspx.vb" Inherits="Index" %>
<html>
<head runat="server">
<title>首页</title>
</head>
<body>
<form id="form1" runat="server">
<asp:Label ID="Lbl" runat="server" Text="用户名"></asp:Label>
<asp:TextBox ID="UserName" runat="server"></asp:TextBox> <br />
<asp:Label ID="Label2" runat="server" Text="密 码"></asp:Label>
<asp:TextBox ID="Password" runat="server"></asp:TextBox>
<br />
<asp:Button ID="Btn_Submit" runat="server" Text="提 交" />
<asp:HyperLink ID="HyperLink1" runat="server">用户注册</asp:HyperLink>
<asp:Label ID="Msg_Lbl" runat="server"></asp:Label><br />
</form>
</body>
</html>
隐藏文件index.aspx.vb
<%@ Page Language="vb"%>
<%@ import namespace="System.Data"%>
<%@ import namespace="System.Data.SqlClient"%>
Partial Class Index
Inherits System.Web.UI.Page
Private connectionstring As String
Dim conn As sqlconnection
Protected Sub Btn_Submit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Btn_Submit.Click
Dim ds As dataset = New dataset
Dim da As SqlDataAdapter = New SqlDataAdapter("select *from users where username='" + UserName.Text + "' and userpwd='" + Password.Text + "'", conn)
conn.open()
da.fill(ds)
If ds.tables(0).rows.count = 0 Then
Msg_Lbl.text = "验证失败!"
Else
Msg_Lbl.Text = "验证成功!"
Session("username") = UserName.Text
Response.Redirect("manage.aspx")
End If
conn.close()
ds.clear()
ds = Nothing
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
connectionstring = System.Configuration.ConfigurationSettings.AppSettings("connectionstring").ToString.Trim
conn = New SqlConnection(connectionstring)
End Sub
End Class
我的代码,有问题吗?怎么改正???
index.aspx
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="index.aspx.vb" Inherits="Index" %>
<html>
<head runat="server">
<title>首页</title>
</head>
<body>
<form id="form1" runat="server">
<asp:Label ID="Lbl" runat="server" Text="用户名"></asp:Label>
<asp:TextBox ID="UserName" runat="server"></asp:TextBox> <br />
<asp:Label ID="Label2" runat="server" Text="密 码"></asp:Label>
<asp:TextBox ID="Password" runat="server"></asp:TextBox>
<br />
<asp:Button ID="Btn_Submit" runat="server" Text="提 交" />
<asp:HyperLink ID="HyperLink1" runat="server">用户注册</asp:HyperLink>
<asp:Label ID="Msg_Lbl" runat="server"></asp:Label><br />
</form>
</body>
</html>
隐藏文件index.aspx.vb
<%@ Page Language="vb"%>
<%@ import namespace="System.Data"%>
<%@ import namespace="System.Data.SqlClient"%>
Partial Class Index
Inherits System.Web.UI.Page
Private connectionstring As String
Dim conn As sqlconnection
Protected Sub Btn_Submit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Btn_Submit.Click
Dim ds As dataset = New dataset
Dim da As SqlDataAdapter = New SqlDataAdapter("select *from users where username='" + UserName.Text + "' and userpwd='" + Password.Text + "'", conn)
conn.open()
da.fill(ds)
If ds.tables(0).rows.count = 0 Then
Msg_Lbl.text = "验证失败!"
Else
Msg_Lbl.Text = "验证成功!"
Session("username") = UserName.Text
Response.Redirect("manage.aspx")
End If
conn.close()
ds.clear()
ds = Nothing
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
connectionstring = System.Configuration.ConfigurationSettings.AppSettings("connectionstring").ToString.Trim
conn = New SqlConnection(connectionstring)
End Sub
End Class
我的代码,有问题吗?怎么改正???