well the login page i did by following a guide. But here is the code from
each page
login.aspx page
<%@ Page Language="C#" Debug="True" %>
<script runat="server">
void LoginBtn_Click(Object sender, EventArgs e) {
if (Page.IsValid) {
System.Data.DataSet userDS = new System.Data.DataSet();
userDS = GetUser(UserName.Text, UserPass.Text);
if (userDS.Tables[0].Rows.Count == 1) {
Session["userid"] = userDS.Tables[0].Rows[0].ItemArray[0];
FormsAuthentication.RedirectFromLoginPage(UserName.Text, false);
}
else {
Msg.Text = "Invalid Credentials: Please try again";
}
}
}
int url(string url) {
string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;
Ole
DB Services=-4; Data Source=z:\\";
System.Data.IDbConnection dbConnection = new
System.Data.OleDb.OleDbConnection(connectionString);
string queryString = "UPDATE [users] SET =@url";
System.Data.IDbCommand dbCommand = new
System.Data.OleDb.OleDbCommand();
dbCommand.CommandText = queryString;
dbCommand.Connection = dbConnection;
System.Data.IDataParameter dbParam_url = new
System.Data.OleDb.OleDbParameter();
dbParam_url.ParameterName = "@url";
dbParam_url.Value = url;
dbParam_url.DbType = System.Data.DbType.String;
dbCommand.Parameters.Add(dbParam_url);
int rowsAffected = 0;
dbConnection.Open();
try {
rowsAffected = dbCommand.ExecuteNonQuery();
}
finally {
dbConnection.Close();
}
return rowsAffected;
}
System.Data.DataSet GetUser(string username, string password) {
string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;
Ole
DB Services=-4; Data Source=Data Source=z:\\";
System.Data.IDbConnection dbConnection = new
System.Data.OleDb.OleDbConnection(connectionString);
string queryString = "SELECT [members].* FROM [members] WHERE
(([members].[username] =
@username) AND (" +
"[members].[password] =
@Password))";
System.Data.IDbCommand dbCommand = new
System.Data.OleDb.OleDbCommand();
dbCommand.CommandText = queryString;
dbCommand.Connection = dbConnection;
System.Data.IDataParameter dbParam_username = new
System.Data.OleDb.OleDbParameter();
dbParam_username.ParameterName = "
@username";
dbParam_username.Value = username;
dbParam_username.DbType = System.Data.DbType.String;
dbCommand.Parameters.Add(dbParam_username);
System.Data.IDataParameter dbParam_password = new
System.Data.OleDb.OleDbParameter();
dbParam_password.ParameterName = "
@Password";
dbParam_password.Value = password;
dbParam_password.DbType = System.Data.DbType.String;
dbCommand.Parameters.Add(dbParam_password);
System.Data.IDbDataAdapter dataAdapter = new
System.Data.OleDb.OleDbDataAdapter();
dataAdapter.SelectCommand = dbCommand;
System.Data.DataSet dataSet = new System.Data.DataSet();
dataAdapter.Fill(dataSet);
return dataSet;
}
</script>
<html>
<head>
</head>
<body style="FONT-FAMILY: arial">
<form runat="server">
<h2>Login Page
</h2>
<hr size="1" />
<table>
<tbody>
<tr>
<td>
Username:</td>
<td>
<asp:TextBox id="UserName"
runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator
id="RequiredFieldValidator1" runat="server" ErrorMessage="*"
Display="Static"
ControlToValidate="UserName"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
Password:</td>
<td>
<asp:TextBox id="UserPass" runat="server"
TextMode="Password"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator
id="RequiredFieldValidator2" runat="server" ErrorMessage="*"
Display="Static"
ControlToValidate="UserPass"></asp:RequiredFieldValidator>
</td>
</tr>
</tbody>
</table>
<asp:button id="LoginBtn" onclick="LoginBtn_Click" runat="server"
text="Login"></asp:button>
<p>
<asp:Label id="Msg" runat="server" forecolor="red"></asp:Label>
</p>
</form>
</body>
</html>
default.aspx page
<%@ Page Language="C#" %>
<script runat="server">
// Insert page code here
//
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<!-- Insert content here -->
</form>
</body>
</html>
:
Did you write this code, or did a Wizard? If a Wizard wrote it, I would
have
to see the code.
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
The sun never sets on
the Kingdom of Heaven
would that work with .net because that's what the login page is next is
the
default.aspx page which has nothing on it. so where would
Response.Redirect(URL String) be placed?
Do you need some code samples?
:
Response.Redirect(URL String)
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
The sun never sets on
the Kingdom of Heaven
Ok this is the setup i have about a 7 or 8 sub-domains that have c#
login
pages and work with 1 access db.
I have to create another sub-domain with subsites under that which
will
belong to the user. I was thinking the layout but some kind of way
to
direct
the user to their own personal subsite depending on their username.
I was told You would have to have a field in the database for each
user
with
the path to their folder, and then redirect them to folder. I have
that
field
in there but i do i re-direct them?