M
mihir.kotwal
I am trying to make a profile page that displays a user's profile
picture if they have added one. If they haven't added a picture, I want
a hyperlink to link to a page to upload it to the server. I have gotten
an upload page working where it stores the server file path on the
server and the corresponding user in an SQL database and then uploads
the picture. I want the hyperlink to link to a page that deletes the
picture if they have one attached to their profile.
Code of the edit profile page:
Partial Class noanon_editprofile
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim conn, rs, sql, pUser
'Visual Studio 2005 Express Edition made me declare the field
or else it would not build
conn = Server.CreateObject("ADODB.Connection")
'I have a conn.Open statement here and I named the field in the
database pUser because ASP was interpreting the field if it was User,
not SQL. I also have aspcompat=True, btw
sql = "SELECT pUser,FileLocation FROM profilepiclocations WHERE
pUser = 'User.Identity.Name'"
rs = conn.execute(sql)
If rs.Fields.Item(pUser) = User.Identity.Name Then
HyperLink3.Text = "Delete profile picture."
HyperLink3.NavigateUrl = "~/noanon/deletepicture.aspx"
Else
HyperLink3.Text = "Add profile picture."
HyperLink3.NavigateUrl = "~/noanon/uploadpicture.aspx"
End If
conn.Close()
End Sub
End Class
I haven't tried scripting the image tag yet. I have played around with
this code and either it didn't work or it gave me errors, like "Item
cannot be found in the collection corresponding to the requested name
or ordinal." What did I do wrong? Is there a better way do do this
through ASP.NET instead of ADO?
-Mihir
picture if they have added one. If they haven't added a picture, I want
a hyperlink to link to a page to upload it to the server. I have gotten
an upload page working where it stores the server file path on the
server and the corresponding user in an SQL database and then uploads
the picture. I want the hyperlink to link to a page that deletes the
picture if they have one attached to their profile.
Code of the edit profile page:
Partial Class noanon_editprofile
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim conn, rs, sql, pUser
'Visual Studio 2005 Express Edition made me declare the field
or else it would not build
conn = Server.CreateObject("ADODB.Connection")
'I have a conn.Open statement here and I named the field in the
database pUser because ASP was interpreting the field if it was User,
not SQL. I also have aspcompat=True, btw
sql = "SELECT pUser,FileLocation FROM profilepiclocations WHERE
pUser = 'User.Identity.Name'"
rs = conn.execute(sql)
If rs.Fields.Item(pUser) = User.Identity.Name Then
HyperLink3.Text = "Delete profile picture."
HyperLink3.NavigateUrl = "~/noanon/deletepicture.aspx"
Else
HyperLink3.Text = "Add profile picture."
HyperLink3.NavigateUrl = "~/noanon/uploadpicture.aspx"
End If
conn.Close()
End Sub
End Class
I haven't tried scripting the image tag yet. I have played around with
this code and either it didn't work or it gave me errors, like "Item
cannot be found in the collection corresponding to the requested name
or ordinal." What did I do wrong? Is there a better way do do this
through ASP.NET instead of ADO?
-Mihir