|
|
|
Hi, thanks for looking
Currently i ask users to sign in each time (i removed the "Remember me" option from the login control)
I initialize some session variables when the user autenthicates
I was wondering what event is the right place to initialize the session if i use the "Remember me" option??
Thanks in advance
Alexei Rodriguez
|
|
|
|
|
Didn't you ask this the other day ? I would assume that you'd have a mechanism in a base page that redirects to the login page if the user is not logged in. If they are logged in, then that seems a good place to check if they are initialised, and if not, to initialise them. Surely the login control also fires an event when the user is logged in ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
It's always better to initialize the session variables when user get authenticated and at the time of logout it should be abondoned.
Cheers!!
Brij
|
|
|
|
|
Thanks for the reply
Thats how i am doing it
The thing is that i would like to enable the remember me option of the login control and initialize the session when the user visits the site again without the need for them to reenter username and password
Alexei Rodriguez
|
|
|
|
|
In that case, you will have code that logs them in, based on whatever. So, do it there.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
For it,read the userName and password and authinticate it and it should be seemless to user ie when user loads the hits the URL it should forwarded to next page
Cheers!!
Brij
|
|
|
|
|
AlexeiXX3 wrote: The thing is that i would like to enable the remember me option
It is done using a cookie. You set some user identification in a cookie when user selects "Remember me next time". When the page loads, read this cookie value and create session for that. I'd create a base page from which all my pages are inherited and do this in base pages OnInit event.
Cookies are kept in local machine, so make sure the information you keep in it is encrypted. So that no one can alter the cookie value and get access to some other account.
|
|
|
|
|
Thanks for the reply
I think that the base page is my best option
Thank you all
Alexei Rodriguez
|
|
|
|
|
I need your help to write Add, Edit and Delete features. Here is the functionality details of the project:
1) SelectAll, ClearAll, Add, Edit and Delete is placed under FooterTemplate,
2) Textboxes for Name and Description is placed in FooterTemplate but its visible property is set to false, it has to be visible only if the Add button is clicked and SelectAll, ClearAll, Edit and Delete should become invisible
3) The edit and delete functionality should be enabled when any of the check box is selected and appropriate button is clicked
and the ASP Code is :
[code]
<![CDATA[<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>]]>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body style="font-family: Tahoma; font-size: smaller">
<script type="text/javascript">
function Sel()
{
var frm = document.forms[0];
for(i=0;i<frm.length;i++)>
{
frm.elements[i].checked=true;
}
}
function DeSel()
{
var frm = document.forms[0];
for(i=0;i<frm.length;i++)>
{
frm.elements[i].checked=false;
}
}
</script>
<form id="form1" runat="server">
<div>
<asp:gridview id="GridView1" runat="server" cellpadding="4" forecolor="Crimson" gridlines="None" xmlns:asp="#unknown">
AutoGenerateColumns="False" BorderColor="Crimson" BorderStyle="Dashed" BorderWidth="2px"
ShowFooter="True" OnRowDataBound="GridView1_RowDataBound" OnRowCommand="GridView1_RowCommand"
OnRowDeleting="GridView1_RowDeleting" OnRowEditing="GridView1_RowEditing" OnRowCreated="GridView1_RowCreated"
OnRowUpdating="GridView1_RowUpdating">
<columns>
<asp:templatefield headertext="S. No.">
<itemtemplate>
<asp:label id="Check" runat="server" text="<%# Bind("sno") %>"></asp:label>
</itemtemplate>
<footertemplate>
<asp:linkbutton id="SelectAll" text="Select All" runat="server" forecolor="White"></asp:linkbutton>
<asp:textbox id="nametb" runat="server" visible="false"></asp:textbox>
</footertemplate>
</asp:templatefield>
<asp:templatefield headertext="Name">
<itemtemplate>
<asp:label id="lblName" runat="server" text="<%# Bind("name") %>"></asp:label>
</itemtemplate>
<edititemtemplate>
<asp:textbox id="ename" runat="server" text="<%# Bind("name") %>"></asp:textbox>
</edititemtemplate>
<footertemplate>
<asp:linkbutton id="ClearAll" text="Clear All" runat="server" forecolor="White"></asp:linkbutton>
<asp:textbox id="Desctb" runat="server" visible="false"></asp:textbox>
</footertemplate>
</asp:templatefield>
<asp:templatefield headertext="Description">
<itemtemplate>
<asp:label id="lblDesc" runat="server" text="<%# Bind("Description") %>" width="300"></asp:label>
</itemtemplate>
<edititemtemplate>
<asp:textbox id="edesc" runat="server" text="<%#Bind("Description") %>"></asp:textbox>
</edititemtemplate>
<footertemplate>
<asp:button id="Add" runat="server" text="Add" width="50" font-names="Tahoma" commandname="add" />
<asp:button id="Edit" runat="server" text="Edit" width="50" font-names="Tahoma" commandname="edit" />
<asp:button id="Delete" runat="server" text="Delete" width="50" font-names="Tahoma">
CommandName="delete" />
</asp:button></footertemplate>
</asp:templatefield>
<asp:templatefield>
<itemtemplate>
<asp:checkbox id="SelectRow" runat="Server" />
</itemtemplate>
</asp:templatefield>
</columns>
<footerstyle backcolor="Crimson" font-bold="True" forecolor="White" />
<rowstyle backcolor="White" forecolor="Crimson" bordercolor="Crimson" borderwidth="2px" />
<pagerstyle backcolor="#FFCC66" forecolor="#333333" horizontalalign="Center" />
<selectedrowstyle backcolor="#FFFFC0" font-bold="True" forecolor="Crimson" />
<headerstyle backcolor="Crimson" font-bold="True" forecolor="White" />
<alternatingrowstyle backcolor="#FFE5E5" bordercolor="#FFCCCC" forecolor="Crimson" />
</asp:gridview>
<asp:label id="Label1" runat="server" xmlns:asp="#unknown"></asp:label></div>
</form>
</body>
</html>
[/code]
My requirement is not to use SQLDataSource rather Data through code.
The ideal output of the GridView looks like this : http://picasaweb.google.co.in/srihariacha/GirdView
Kindly help me !
Regards,
Sri Hari Acha
|
|
|
|
|
This reads like you're asking us to write it for you. You can use any data source you like, but without persistence of some sort, what's the point of adding and editing data that will be lost ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Hi All,
I involved in developing a web project, I do login page to new users can registered on my web page. the problem how I can user maintain in all pages he navigate to. any help plz.
Regards
|
|
|
|
|
I user Sessions. Basically, when a user logs in , i carry the Username, to Display a message like Welcome "James" and each and every page i check if the Session is new, that means i chech if the Session variable is empty if its new, the user must be redirected to the login page. Now when the User logs off , i abandon the Session.
Hope it helps
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
thanks a lot that was very helpful.
King Regards
|
|
|
|
|
Session variables are the best option to use it.Also you can use some database for logging the details of every user.
Cheers!!
Brij
|
|
|
|
|
As the others have mentioned, use session variables. Do make sure when you are done with the user's session variable to delete it when finished. Otherwise, you will eventually (as this may take a very long time to have happen) run out of memory on the server where the values are kept.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
The one step no-one else mentioned, is to create a new base page, which redirects to the login page if the user is not already logged in. From there, it just works.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Good point.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Would you believe I inherited a project that didn't bother to do this ? If you went to a URL inside the site directly, it would just work, or blow up on the basis of missing sessions variables ( not the login, all sorts of other stuff was being stored in the session and never checked when it was accessed ).
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Christian Graus wrote: I inherited a project that didn't bother to do this
Oh boy, I bet that was loads of joy fixing that up.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
That was just one example, that whole site was a nightmare. The other big thing that blew my mind was that all session variables were strings, and all strings were typed in everywhere. I actually found code like this:
if (Session["WeShouldDoStuffNow"] == "YES")
when doing some searching proved that it was only ever set to Yes, or No. I obviously centralised all the 'WeShouldDoStuffNow' values to a class, so that there were never typos, but I gave up, I defined YES and NO rather than move to bools.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Christian Graus wrote: session variables were strings, and all strings were typed in everywhere
Those can be a problem. Session variables are going to be a part of my discussion this up coming Tuesday evening in my VB.NET class I teach. I try to emphasize the importance of doing something like:
Dim MyUser As String = "UserName"
If Session[MyUser] blah blah blah blah Then
....
is easier and safer to work with than having the variable name inside quotations. It is a point I try to get across, and usually get mixed mileage every semester.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Yeah, I would create a class that contains all the strings, and use it throughout the site. It's hard to believe that anyone would fail to understand how important that is, once it's explained to them.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Christian Graus wrote: would create a class that contains all the strings, and use it throughout the site.
Hmmmm, that sounds like a nice little final exam problem [evil grin]...
Christian Graus wrote: It's hard to believe that anyone would fail to understand how important that is, once it's explained to them.
It happens from time to time, usually the student who is too busy IM'ing someone and not paying attention to the discussion. After they spend about two hours trying to debug the errors caused by the typos, it finally clicks.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|