【发布时间】:2013-04-15 01:51:39
【问题描述】:
我有一个编辑个人资料页面,允许用户更改他们的信息 - 目前它只允许在“userprofiles”表中有记录的用户编辑他们的信息。我希望新注册的用户也能够编辑他们的个人资料。
此时,我正在使用 ASP.NET 会员系统和 Access 数据库中的适当 asp.net_ 表来存储用户凭据。 'userprofiles' 表是一个单独的表,其中包含更多个人信息。两个表之间没有链接
这是我的代码:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If IsCrossPagePostBack Then SeparateNewUserFunction() Return End If If Not IsPostBack Then DisplayData() SaveConfirmation.Visible = False End If End Sub
如果有人对它的作用感兴趣,这是我的 DisplayData() 函数:
Protected Sub DisplayData() Dim conn As OleDbConnection = New OleDbConnection(ConfigurationManager.ConnectionStrings("BookMeetConnString").ConnectionString) Dim sql = "SELECT * FROM userprofiles WHERE TravellerName=@f1" Dim cmd = New OleDbCommand(sql, conn) cmd.Parameters.AddWithValue("@f1", User.Identity.Name) conn.Open() Dim profileDr = cmd.ExecuteReader() profileDr.Read() Dim newEmailAddress = "" Dim newDescription = "" If Not IsDBNull(profileDr("EmailAddress")) Then newEmailAddress = profileDr.Item("EmailAddress") If Not IsDBNull(profileDr("Description")) Then newDescription = profileDr.Item("Description") If Not IsDBNull(profileDr("AvatarURL")) Then ProfilePic.ImageUrl = profileDr.Item("AvatarURL") description.Text = newDescription email.Text = newEmailAddress conn.Close() End Sub
与其检查“userprofiles”表中是否存在与当前用户的 User.Identity.Name 匹配的记录,我认为只评估用户是否刚刚从注册表重定向会更容易.aspx 页面。 (如果这个评估是真的,那么正如你在上面看到的,一个单独的“新用户”函数将被调用)。
这是我的逻辑,但我不知道 VB.NET 是否有“referrer”或“isReferred”表达式? (正如你所见,我认为 isCrossPagePostback 可能是正确的,但没有运气!)
有什么想法吗?
【问题讨论】:
-
我还强烈建议您同时学习 ASP.NET MVC,或者在您熟悉 Web 表单之后不久。
-
好的,谢谢。我会调查的!
标签: asp.net vb.net ms-access postback