TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Israel
631
1.3k
217.4k
Want to see the real username appear on the next page
Jan 23 2014 6:46 AM
Hi!
I putted a "label" on my next page that I want to mention the real username after log in
Then this username should appear on the next page ONLY when the username and password are correct
How can I do it? this my codes:
protected
void
log_Click(
object
sender,
EventArgs
e)
{
SqlDataSource
sds =
new
SqlDataSource
();
sds.ConnectionString =
ConfigurationManager
.ConnectionStrings[
"master"
].ToString();
sds.SelectParameters.Add(
"username"
,
TypeCode
.String,
this
.username.Text);
sds.SelectParameters.Add(
"password"
,
TypeCode
.String,
this
.password.Text);
sds.SelectCommand =
"SELECT * FROM [myTb] WHERE [username] = @username AND [password] = @password"
;
DataView
dv = (
DataView
)sds.Select(
DataSourceSelectArguments
.Empty);
try
{
if
(dv.Count == 0)
{
this
.lblinfo.ForeColor = System.Drawing.
Color
.Red;
this
.lblinfo.Text =
"Invalid username and password!"
;
return
;
}
else
{
FormsAuthentication
.RedirectFromLoginPage(username.Text,
true
);
Response.Redirect(
"~/English/Visual.aspx"
);
//It's here where I need the codes
}
}
catch
{
}
finally
{
}
}
}
Reply
Answers (
3
)
Symbols in MVC4 Razor
Reg: .Net Framework 4.0 Features