if intID <> 0 then
Session("EmployeeID") = intID
FormsAuthentication.RedirectFromLoginPage(intID, false)
Response.Redirect("Webform2.aspx")
I've checked and the value is being stored ok - it can be printed out on this form. However on my second form I have this...
txtID.Text = HttpContext.Current.Session("EmployeeID")
...but the value is not retrieved. I've tried it with cookies and with ViewState as well and can't get anything to pass the values over.
Any help much appreciated!Hmm, if no state saving mechanism (cookies, viewstate, session, etc) is holding a value, then I would say that there is a problem with the flow of how the code executes. Ie, you're requesting the value before it's been initialized. Perhaps posting the necessary code for both pages would help clarify the problem.
Hello, try to use
HttpContext.Current.Session("EmployeeID").ToString()
regards
I'm passing two strings (username, password) to a business object which returns an integer (employeeID). The following procedure is called when the user clicks a button to login. It is working fine and if I disable the link, put a textbox on the page and call the session variable, the value is there all right...
<%@. Import namespace="UserAuthentication" %>
<%@. Page Language="vb" EnableSessionState="True" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="InventoryManager.WebForm1"%>
<%@. Register TagPrefix="Inventory" TagName="Footer" src="http://pics.10026.com/?src=footer.ascx" %>
<%@. Register TagPrefix="Inventory" TagName="Header" src="http://pics.10026.com/?src=header.ascx" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<script runat="server"
sub Login(obj as object, e as EventArgs)' UserAuthentication is the namespace name
' AuthenticateUser is the class inside it
dim objUser as New UserAuthentication.AuthenticateUser
dim intID as integer' Login is a method of the AuthenticateUser class
intID = objUser.Login(txtUserName.Text, txtPassword.Text)if intID <> 0 then
Session("EmployeeID") = intID
FormsAuthentication.RedirectFromLoginPage(intID, false)
Response.Redirect("Webform2.aspx")
else
lblMessage.Visible = True
lblMessage.Text="Invalid Login"
end ifend sub
</script>
Then on the page this redirects to...
Imports System.Web.Security ' Required Class for Authentication
Imports System.Data ' DB Accessing Import
Imports System.Data.OleDb ' Access Database Required Import
Imports System.Configuration ' Required for Web.Config appSettings
Imports System.WebPublic Class WebForm2
Inherits System.Web.UI.Page
Dim MyConn As OleDbConnection = New OleDbConnectio(ConfigurationSettings.AppSettings("strConn"))Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
' Fill the Listbox with Product Items
ListLoad()
MyConn.Close()
txtID.Text = HttpContext.Current.Session("EmployeeID")
End IftxtID.Text = HttpContext.Current.Session("EmployeeID")
End Sub
But this doesn't retrieve the value.
OK haider, I'll try that this evening.
ok, please do test it and reply back to me, to follow up with you. there shouldn't be any problem.
regards
Sorry haider, that didn't work either.
Hello,
I am having similar problems. I store a value in a session variable from a textbox - Session("IDate") = textbox1.text
The value is in the session variable. I then call the new page with this Response.Redirect("Newpage.aspx")
On the new page I am trying to store the value into another text box, but no value is there. I can issue a Response.Writre(Session("IDate")) and the value is displayed. But if I use tbxStartDate.Text = Session("IDate").ToString() the value is not entered in the text box. Any suggestions?
Mike
0 comments:
Post a Comment