I need to figure out how to bind data and call it back anywhere on the page. Basically, this is what I am trying to do. Keep in mind that I am an asp programmer and am very new to ASP.NET.
I have build a custom login page that works. Now I need to retrieve the number of comments from a database and post it like I did in asp. Also, I need to retrieve a users id and post it in multiple places randomly on the page. Thanks.
I am converting an asp site to asp.net.
Sub btnLogin_Click(S As Object, E As EventArgs)
Dim loginValid As String
Dim conLogin As OdbcConnection
Dim cmdSelectLoginfo As OdbcCommand
Dim dtrReaderLogin As OdbcDataReader
Dim conStringLogin As String
Dim SQLString As String
Dim cmdSelectComments As OdbcCommand
Dim dtrReaderComments As OdbcDataReader
Dim SQLComments As String
Dim strUAID As String
Dim arow as datarow
conStringLogin = System.Configuration.ConfigurationSettings.AppSettings.Get("ConnectionString")
conLogin = New OdbcConnection( conStringLogin )
SQLString = "SELECT UserID FROM Users WHERE UserName='" & txtUsername.Text & "' AND UserPassword='" & txtPassword.Text & "'"
cmdSelectLoginfo = New OdbcCommand( SQLString, conLogin )
conLogin.Open()
dtrReaderLogin = cmdSelectLoginfo.ExecuteReader()
if dtrReaderLogin.hasrows then
conLogin.Close()
Session("Login") = "Logged"
hypAccount.NavigateURL = "/Vegas2/MyAccount/account.aspx?uaID=" & arow("UserID") & ""
SQLComments = "SELECT COUNT(*) AS Comments FROM Comments WHERE ReadComment='No' AND UAID=" & arow("UserID") & ""
cmdSelectComments = New OdbcCommand( SQLComments, conLogin )
conLogin.Open()
dtrReaderComments = cmdSelectComments.ExecuteReader()
if dtrReaderComments.hasrows then
hypComments.Visible = True
hypComments.NavigateURL = "/Vegas2/MyAccount/comments.aspx?uaID=" & arow("UserID") & ""
hypComments.Text = "New Comments!"
else
hypComments.Visible = False
end if
dtrReaderLogin.Close()
dtrReaderComments.Close()
conLogin.Close()
else
Session("Login") = "Failed"
conLogin.Close()
dtrReaderLogin.Close()
end if
If (Session("Login") = "Logged") then
pnlLogin.Visible = False
pnlLogged.Visible = True
pnlForgotPass.Visible = False
ElseIf (Session("Login") = "Failed") then
pnlLogged.Visible = False
pnlLogin.Visible = True
pnlForgotpass.Visible = True
Else
pnlLogged.Visible = False
pnlLogin.Visible = True
pnlForgotpass.Visible = False
End If
End Sub