•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 423,539 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,235 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 2979 | Replies: 9
![]() |
•
•
Join Date: Nov 2007
Posts: 18
Reputation:
Rep Power: 1
Solved Threads: 0
hi all,
I have to maintain a Session variable in the Login page, which is used to keep login information for user.
It is not required for user to go for login and access all pages. I mean that if user has an account then he/she can get login otherwise it is not necessary to go for login, they still can access all pages.
I store "no" string in the session variable in the login page, if user does not get logged.
The problem is that when I want to retrieve string from this variable in other pages, and user did not get logged, then I always get error that 'Session variable is not created'. How I can solve this problem?
Please reply as soon as possible.
Thanks.
I have to maintain a Session variable in the Login page, which is used to keep login information for user.
It is not required for user to go for login and access all pages. I mean that if user has an account then he/she can get login otherwise it is not necessary to go for login, they still can access all pages.
I store "no" string in the session variable in the login page, if user does not get logged.
The problem is that when I want to retrieve string from this variable in other pages, and user did not get logged, then I always get error that 'Session variable is not created'. How I can solve this problem?
Please reply as soon as possible.
Thanks.
•
•
Join Date: Nov 2007
Posts: 18
Reputation:
Rep Power: 1
Solved Threads: 0
In the Login Page I have done:-
And tried to get Sessin value in other pages.
by:- string s=Session["login"].ToString();
but I get error that Session variable is not created.
protected void Page_Load(object sender, EventArgs e)
{
Session["login"] = "no";
}
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
{
if (myObj.UserLogin(Login1.UserName, Login1.Password) == "exists")
{
Response.Redirect("HomePage.aspx");
Session["login"] = Login1.UserName;
}
else
Response.Write("Please verify UserName or Password");
}And tried to get Sessin value in other pages.
by:- string s=Session["login"].ToString();
but I get error that Session variable is not created.
•
•
Join Date: Nov 2007
Posts: 18
Reputation:
Rep Power: 1
Solved Threads: 0
hi
thanks for giving time in my problem.
Actually my problem is that how I can maintain login information accessiable in all the pages of the website.
Is there any other solution for it rather then using Session variable.
If I use Session variable in login page, then if user access other page of the website directly then there error will be occure that Session variable is not created.
Please solve my problem, I got tired with this work.
thanks
thanks for giving time in my problem.
Actually my problem is that how I can maintain login information accessiable in all the pages of the website.
Is there any other solution for it rather then using Session variable.
If I use Session variable in login page, then if user access other page of the website directly then there error will be occure that Session variable is not created.
Please solve my problem, I got tired with this work.
thanks
Hi, I have found the best way to pass user information between pages is with Server.Transfer("~/page.aspx", true)
what you do is first create the string you want to pass between pages
ON SOME MOUSE CLICK OR EVENT:
dim isvalidated as string
dim username as string
isvalidated = "Yes"
username = "eric"
context.items.add("isvalid", isvalidated)
context.items.add("usern", username)
server.transfer("~/page.aspx", true)
---
once it goes to the new page you can "retrieve" these values
dim isvalid as string
dim usern as string
ON PAGELOAD FOR NEXT PAGE
isvalid = context.items("isvalid")
usern = context.items("usern")
what i usually do is validate at this point...
if isvalid = "" then
server.transfer("~/notauthorized.aspx")
else
DO WHATEVER YOU WANT
...
end if
what you do is first create the string you want to pass between pages
ON SOME MOUSE CLICK OR EVENT:
dim isvalidated as string
dim username as string
isvalidated = "Yes"
username = "eric"
context.items.add("isvalid", isvalidated)
context.items.add("usern", username)
server.transfer("~/page.aspx", true)
---
once it goes to the new page you can "retrieve" these values
dim isvalid as string
dim usern as string
ON PAGELOAD FOR NEXT PAGE
isvalid = context.items("isvalid")
usern = context.items("usern")
what i usually do is validate at this point...
if isvalid = "" then
server.transfer("~/notauthorized.aspx")
else
DO WHATEVER YOU WANT
...
end if
•
•
Join Date: Oct 2005
Posts: 54
Reputation:
Rep Power: 3
Solved Threads: 0
Dear Colleagues:
I want to separate interface design from its code (in my asp.net school project). So that , I'm trying to use a code-behind using vb.net. For example in my login page I provide the user with username and password input, then handle the user input from lgoin.vb file. But I don't know how to get the values of textbox that are placed in login.aspx file.
How Can access these username and password textbox values in the login.vb code to check the user input. To give u some idea about my code, just see the following simple code:
************************
login.aspx
************************
<%@ page Inherits ="class1" scf="lgoin.vb"%>
<html>
<head></head>
<body>
<form id="form1" runat="server">
<asp:TextBox ID="txtuname" runat="server"/>
<asp:TextBox ID="txtpass" runat="server"/>
<asp:Button ID="btnlog" runat="server" Text="Button" OnClick ="button_click" />
</form>
</body>
</html>
************************
login.vb
************************
Imports Microsoft.VisualBasic
Imports system.Web
Imports system.Web.UI
Imports system.Web.UI.Control
Imports system.Web.UI.HtmlControls
Public Class Class1
Inherits Page
Sub button_click(ByVal s As Object, ByVal e As EventArgs)
'based on the the user input(username and passward)
' I want to redirect the users to different pages
' if txtpass.text= "x" and txtuname="something" then
'Response.Redirect("x.aspx")
'else
'Response.Redirect("y.aspx")
End Sub
End Class
************************
As u have seen from the code I commented some lines on login.vb file. This is because I can't access the txtuname and txtpass textboxes from lgoin.vb.
Please help me how can I do that
Regards,
Ben
I want to separate interface design from its code (in my asp.net school project). So that , I'm trying to use a code-behind using vb.net. For example in my login page I provide the user with username and password input, then handle the user input from lgoin.vb file. But I don't know how to get the values of textbox that are placed in login.aspx file.
How Can access these username and password textbox values in the login.vb code to check the user input. To give u some idea about my code, just see the following simple code:
************************
login.aspx
************************
<%@ page Inherits ="class1" scf="lgoin.vb"%>
<html>
<head></head>
<body>
<form id="form1" runat="server">
<asp:TextBox ID="txtuname" runat="server"/>
<asp:TextBox ID="txtpass" runat="server"/>
<asp:Button ID="btnlog" runat="server" Text="Button" OnClick ="button_click" />
</form>
</body>
</html>
************************
login.vb
************************
Imports Microsoft.VisualBasic
Imports system.Web
Imports system.Web.UI
Imports system.Web.UI.Control
Imports system.Web.UI.HtmlControls
Public Class Class1
Inherits Page
Sub button_click(ByVal s As Object, ByVal e As EventArgs)
'based on the the user input(username and passward)
' I want to redirect the users to different pages
' if txtpass.text= "x" and txtuname="something" then
'Response.Redirect("x.aspx")
'else
'Response.Redirect("y.aspx")
End Sub
End Class
************************
As u have seen from the code I commented some lines on login.vb file. This is because I can't access the txtuname and txtpass textboxes from lgoin.vb.
Please help me how can I do that
Regards,
Ben
•
•
Join Date: Dec 2007
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
This depends on a lot of things. How are you validating users in the first place? Using a database, using the web.config file? If you are using a database, it would be something like the following:
Dim Myconn As SqlConnection = New SqlConnection("server=localhost; database=dbaseName; Trusted_Connection=Yes")
Dim DBselect As String
DBselect = "select whatever from table_namewhere some condition"
Dim Mycommand As SqlCommand = New SqlCommand(DBselect, Myconn)
'Feed Parameter to database get the access level
Mycommand.Parameters.Add("@param", SqlDbType.VarChar).Value = txtUName.value
Dim Myconn As SqlConnection = New SqlConnection("server=localhost; database=dbaseName; Trusted_Connection=Yes")
Dim DBselect As String
DBselect = "select whatever from table_namewhere some condition"
Dim Mycommand As SqlCommand = New SqlCommand(DBselect, Myconn)
'Feed Parameter to database get the access level
Mycommand.Parameters.Add("@param", SqlDbType.VarChar).Value = txtUName.value
![]() |
•
•
•
•
•
•
•
•
DaniWeb ASP.NET Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
.net .net framework 3.0 access adobe advice advive ajax asp classification code combo complete information custom cybercrime data developer development dom dropdownlist feed forensic help help.forensic information microsoft module msdn net nhatquanglan office password pdf privacy ransomware reader reuse security skin spam sql strength svchost theme vista weather web windows workflow xml xoap you tried to assign the null value to a variable that is not a variant data type
- Previous Thread: Creating and opening MS WORD(ReadOnly)
- Next Thread: html to PDF conversion Code in c#


Linear Mode