请看一下下面的代码:
private sub page_load(sender As Object, e As EventArgs)
if  request.cookies.item("us")=dbNULL thenresponse.cookies.item("us").expires=now.addmonths(1)
textbox1.text=response.cookies("us").value
end if
end subSub CheckBox1_CheckedChanged(sender As Object, e As EventArgs)
response.cookies("us").value=textbox1.text
response.cookies.item("us").expires=now.addmonths(1)
End Sub我想让cookie记住用户名,可怎么不正确?

解决方案 »

  1.   

    If Request.Cookies.Item("us") Is Nothing Then
    response.cookies.item("us").expires=now.addmonths(1)
    textbox1.text=response.cookies("us").value
    end if
    end sub
      

  2.   

    是== 不是=if  request.cookies.item("us") == dbNULL then
      

  3.   

    if  request.cookies.item("us") == "dbNULL" then
      

  4.   

    dbNULL?没看到new HttpCookie的代码,光判断有啥用
      

  5.   

    楼上的  ==是C#里面用的  楼主VB的 用=
      

  6.   

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
        If Not IsPostBack Then
            If Not Request.Cookies("username") Is Nothing Then
                Response.Write("last cookid username is " + Request.Cookies("username").Value)
            End If
        End If
    End SubPrivate Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Request.Cookies.Clear()
        Response.Cookies("username").Value = Format(Now, "yyyy-MM-dd HH:mm:ss")
        Response.Cookies("username").Expires = Now.AddMonths(1)    Response.Write("current cookie username is " + Request.Cookies("username").Value)
    End Sub