if ...... then 
  "请输入您的真实姓名!"
else
   INSERT INTO database
   response.redirect("ok.aspx")
end if

解决方案 »

  1.   

    这是我的代码:
     Private Sub btsubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btsubmit.Click
            If Page.IsValid Then
                Dim myconnection As OleDb.OleDbConnection
                Dim mycommand As OleDb.OleDbCommand
                Dim mycommand2 As OleDb.OleDbCommand
                Dim newuser As String
                Dim insertstring As String
                Dim querystring As String
                Dim useraddress As String
                Dim userbirthday1 As String
                Dim userbirthday As Date
                Dim registerdate As Date
                querystring = "Select  * from userinfo where(username='" + tbusername.Text + "')"
                myconnection = New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("db\info.mdb"))
                mycommand2 = New OleDb.OleDbCommand(querystring, myconnection)
                myconnection.Open()
                Dim myReader As OleDb.OleDbDataReader
                myReader = mycommand2.ExecuteReader()
                If myReader.HasRows Then
                    Page.RegisterStartupScript("MsgBox", "<script>alert('用户名:" & tbusername.Text & "已存在!');</script>")
                    myReader.Close()
                    myconnection.Close()
                Else
                    Dim sexstring As String
                    If RMan.Checked Then
                        sexstring = "男"
                    Else
                        sexstring = "女"
                    End If
                    myReader.Close()
                    registerdate = Now()
                    useraddress = province.SelectedItem.Text & tbcity.Text & tbaddress.Text
                    userbirthday1 = tbyear.Text & "," & month.SelectedItem.Text & "," & day.SelectedItem.Text
                    userbirthday = CDate(userbirthday1)
                    insertstring = "Insert into userinfo(username,passward,question,answer,name,sex,address,birthday,email,phone,registerdate,online) values('" + tbusername.Text + "','" + tbpassward.Text + "','" + question.SelectedItem.Text + "','" + tbanswer.Text + "', '" + tbname.Text + "','" + sexstring + "','" + useraddress + "','" + userbirthday + "','" + tbemail.Text + "','" + tbphone.Text + "','" + registerdate + "','false')"
                    mycommand = New OleDb.OleDbCommand(insertstring, myconnection)
                    mycommand.ExecuteNonQuery()
                    myconnection.Close()
                    'Label1.Text = "注册成功!!"
                    newuser = tbusername.Text
                    tbpassward.Text = ""
                    tbrepassward.Text = ""
                    tbname.Text = ""
                    tbcity.Text = ""
                    tbaddress.Text = ""
                    tbyear.Text = ""
                    tbaddress.Text = ""
                    tbemail.Text = ""
                    tbphone.Text = ""
                    Page.RegisterStartupScript("MsgBox", "<script>alert('新用户:" & newuser & ",注册成功!');</script>")
                    Response.Redirect("index.aspx?user=" & System.Web.HttpUtility.UrlEncode(newuser))            End If
            End If
        End Sub
      

  2.   

    页面跳转的实现:Response.Write("要跳转的页面");
    实现后退页面:Response.Write("<script>history.back(-1);script>");
    如果要实现后退(B后退到A)后显示的页面自动刷新,在B中加:
    Response.CacheControl = "no-cache";
      

  3.   

    不是这样子喔。。我的意思实说,如果我在页面那里添加了一个TextBox控件,然后加了一个验证控件RequiredFieldValidator,那么我想实现,如果验证通过则跳转到NEXT.ASPX,否则出示错误信息,并不跳转页面...怎么实现?
      

  4.   

    在加一个Validationsummary验证控件,这样就能出示错误信息并不跳转页面。
    如果验证通过则跳转到NEXT.ASPX:
     Private Sub btresume_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btresume.Click
            Response.Redirect("next.aspx")
     End Sub