Click here to Skip to main content
15,899,679 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: MDI child window maximize through title-bar double-click Pin
angusmax22-May-09 0:02
angusmax22-May-09 0:02 
GeneralRe: MDI child window maximize through title-bar double-click Pin
Dave Kreskowiak22-May-09 12:55
mveDave Kreskowiak22-May-09 12:55 
GeneralRe: MDI child window maximize through title-bar double-click Pin
angusmax28-May-09 0:07
angusmax28-May-09 0:07 
QuestionHow to use perfmon Pin
krishnan.s11-May-09 23:31
krishnan.s11-May-09 23:31 
AnswerRe: How to use perfmon Pin
Simon P Stevens12-May-09 0:23
Simon P Stevens12-May-09 0:23 
QuestionNeed help in code-behind Pin
Senthil S11-May-09 21:23
Senthil S11-May-09 21:23 
AnswerRe: Need help in code-behind Pin
Samer Aburabie12-May-09 20:40
Samer Aburabie12-May-09 20:40 
QuestionHow to use "Session" variables?? Pin
lsh486love11-May-09 21:21
lsh486love11-May-09 21:21 
I'm making a login page with ASP.NET with C#.

and I know that it needs to use Session for saving information of loggined user.

so I used Session like this on "login.aspx.cs" with Login View Control.


[login.aspx.cs]



// Database query.

SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["Join"].ConnectionString);
SqlCommand cmd = new SqlCommand("SELECT * From User WHERE id = @ID", con);
cmd.Parameters.AddWithValue("@ID", ((TextBox)LoginView1.FindControl("TextBox1")).Text);

string name = rd["name"].ToString();
string pw = rd["password"].ToString();
string pw1 = ((TextBox)LoginView1.FindControl("TextBox2")).Text;
string id = rd["id"].ToString();

// Save to Session variables. There are a lot of components about Session. Keys, Item, Add,
//and so on..

Session["memberid"] = id;
Session["membername"] = name;

if ((string.Equals(pw, pw1)) == true)
{
FormsAuthentication.RedirectFromLoginPage(name, false);
}

....
And I made codes like this whether lggined user is same with Writer on board or not.


[Board.aspx]


public static bool IsWriter(string pdsId, string Writer)
{

string sql = "Select id From t_Pds Where boardId = @boardId And writer = @writer";
SqlCommand cmd = new SqlCommand(sql, DbConn.GetConn());

cmd.Parameters.AddWithValue("@boardId", pdsId);
cmd.Parameters.AddWithValue("@writer", Writer);
cmd.Connection.Open();
string result = (string)cmd.ExecuteScalar(); // result = ID of writer value.
cmd.Connection.Close();


// I can't use Session. When I use "Session", there are no components of Session.
// There are only two values of Session. ( SessionPageStatePersister , SessionParameter)

if (Session["memberid"] == result) //ERROR.
{
return true;
}
else
return false;

}


}


How can I use Session for saving information of User and how can I compare with Writer on Board?? Is there sample code??
AnswerCP IGNORE: Cross-posting Pin
Rajesh R Subramanian11-May-09 21:52
professionalRajesh R Subramanian11-May-09 21:52 
QuestionQuestion regarding File SreamReader in VB.NET Pin
bheeem11-May-09 21:05
bheeem11-May-09 21:05 
QuestionDebug Windows service Pin
Sundeep Ganiga11-May-09 18:27
Sundeep Ganiga11-May-09 18:27 
AnswerRe: Debug Windows service Pin
Mark Salsbery12-May-09 7:13
Mark Salsbery12-May-09 7:13 
GeneralRe: Debug Windows service Pin
Sundeep Ganiga13-May-09 1:35
Sundeep Ganiga13-May-09 1:35 
GeneralRe: Debug Windows service Pin
Mark Salsbery13-May-09 6:11
Mark Salsbery13-May-09 6:11 
Question.Net Configuration Tool Pin
Roger Wright11-May-09 15:22
professionalRoger Wright11-May-09 15:22 
QuestionGrouping of Colors to "main" color / nuance. Pin
mm-2k11-May-09 7:49
mm-2k11-May-09 7:49 
Questionadding atext to atextbox in section 1 in crystalreport c# Pin
Member 439903611-May-09 7:21
Member 439903611-May-09 7:21 
QuestionActive Directory Pin
jarbo3a11-May-09 2:05
jarbo3a11-May-09 2:05 
AnswerRe: Active Directory Pin
glumlord12-May-09 8:15
glumlord12-May-09 8:15 
Question.Net memory usage Pin
krishnan.s10-May-09 22:08
krishnan.s10-May-09 22:08 
AnswerRe: .Net memory usage Pin
Eddy Vluggen10-May-09 22:23
professionalEddy Vluggen10-May-09 22:23 
AnswerRe: .Net memory usage Pin
Eddy Vluggen10-May-09 22:40
professionalEddy Vluggen10-May-09 22:40 
AnswerRe: .Net memory usage Pin
Simon P Stevens11-May-09 0:05
Simon P Stevens11-May-09 0:05 
QuestionUnable to connect to SQL Server database Pin
v.narasa10-May-09 19:17
v.narasa10-May-09 19:17 
AnswerRe: Unable to connect to SQL Server database Pin
Atif Shahbaz10-May-09 20:04
Atif Shahbaz10-May-09 20:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.