我怎么能登录的价值转移到另一个页面? [英] How can I transfer login value to another page?
问题描述
我是新手在使用asp.net与code vb.net的后面,我只是想知道如何看到POS页的管理员的名称。看来这code不起作用?
Main.lbl_name.Text = CurName.ToUpper
POS.lbl_cashier.Text = CurName.ToUpper保护小组的button1_Click(BYVAL发件人为对象,BYVAL E上System.EventArgs)把手Button1.Click 昏暗CMD1作为新的SqlCommand
昏暗的RDR作为SqlDataReader的 cmd1.Connection = CN
cmd1.Connection.Open()
cmd1.CommandText =SELECT * FROM为UserTable其中username ='&放大器; txt_username.Text&安培; '
RDR = cmd1.ExecuteReader 如果rdr.HasRows = TRUE,则
rdr.Read()
如果txt_username.Text = rdr.Item(0)和txt_password.Text = rdr.Item(3)然后
CURPOS = rdr.Item(类型)
CurUser = rdr.Item(用户名)
CurName = rdr.Item(EmployeeName) 如果rdr.Item(4)=管理员然后
MSGBOX(欢迎光临!&放大器; rdr.Item(4),MsgBoxStyle.Information)
Main.lbl_name.Text = CurName.ToUpper
POS.lbl_cashier.Text = CurName.ToUpper
cmd1.Connection.Close()
的Response.Redirect(ACESCHOOLSUPPLIES.aspx)
Me.Dispose()
您不能随便访问其他网页,ASP.NET运行时是无知其他页面,您可以访问您的当前页面而已!
您可以使用Session变量暂时存储一些数据,当前用户会话,会话对象可在每一个ASP.NET页面。
会议(adminname)= CurName
在其他页面,你要显示它您刚刚从会话重新加载
昏暗的新名称=会议(adminname)
I am a newbie in using asp.net with code behind of vb.net I just wanna know on how to see the name of the admin on the POS page. it seems that this code doesn't work??
Main.lbl_name.Text = CurName.ToUpper
POS.lbl_cashier.Text = CurName.ToUpper
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim cmd1 As New SqlCommand
Dim rdr As SqlDataReader
cmd1.Connection = cn
cmd1.Connection.Open()
cmd1.CommandText = "SELECT * from UserTable WHERE Username ='" & txt_username.Text & "'"
rdr = cmd1.ExecuteReader
If rdr.HasRows = True Then
rdr.Read()
If txt_username.Text = rdr.Item(0) And txt_password.Text = rdr.Item(3) Then
CurPos = rdr.Item("Type")
CurUser = rdr.Item("Username")
CurName = rdr.Item("EmployeeName")
If rdr.Item(4) = "ADMINISTRATOR" Then
MsgBox("WELCOME! " & rdr.Item(4), MsgBoxStyle.Information)
'Main.lbl_name.Text = CurName.ToUpper
'POS.lbl_cashier.Text = CurName.ToUpper
cmd1.Connection.Close()
Response.Redirect("ACESCHOOLSUPPLIES.aspx")
'Me.Dispose()
You can't just access other pages, ASP.NET runtime is ignorant about other pages, you have access to your current page only!
You can use the Session variable to store some data temporarily for current user session, the Session object is available on every ASP.NET Page.
Session("adminname") = CurName
On other page where you want to show it you just reload it from Session
Dim NewName = Session("adminname")
这篇关于我怎么能登录的价值转移到另一个页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!