Click here to Skip to main content
15,891,253 members
Home / Discussions / C#
   

C#

 
GeneralRe: XSL Variable in .cs File Pin
Stefan Troschuetz23-Feb-07 0:32
Stefan Troschuetz23-Feb-07 0:32 
QuestionFetch last record of table Pin
Nekshan22-Feb-07 20:08
Nekshan22-Feb-07 20:08 
AnswerRe: Fetch last record of table Pin
il_masacratore22-Feb-07 21:23
il_masacratore22-Feb-07 21:23 
AnswerRe: Fetch last record of table Pin
althamda22-Feb-07 22:27
althamda22-Feb-07 22:27 
AnswerRe: Fetch last record of table Pin
virendra patel23-Feb-07 16:37
virendra patel23-Feb-07 16:37 
QuestionFont size increases after postback Pin
Bobb198222-Feb-07 20:01
Bobb198222-Feb-07 20:01 
AnswerRe: Font size increases after postback Pin
Harini N K22-Feb-07 21:29
Harini N K22-Feb-07 21:29 
QuestionDisplay LoginName from LoginControl Pin
SharonRao22-Feb-07 19:59
SharonRao22-Feb-07 19:59 
Hello All,

I have a web page with login control binded to custom sql membershipProvider to authorise the user. I was trying to use GetUser() method to display username but it is giving an error, I think i need to override

Membership.GetUser() method as well becos i understand its not using my custom SQL membership provider to get the loginname but iam stuck dont know how to acheive that. can someone help me out here, please see code below.

Login.aspx.cs


protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
{


bool Authenticated = false;
Authenticated = SiteLevelCustomAuthenticationMethod(Login1.UserName, Login1.Password);

e.Authenticated = Authenticated;


if (Authenticated == true)
{

Response.Redirect(

"Welcome.aspx");
}

}


private bool SiteLevelCustomAuthenticationMethod(string UserName, string Password)
{

System.Data.SqlClient.

SqlConnection Con = new System.Data.SqlClient.SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
System.Data.SqlClient.

SqlCommand Cmd = new System.Data.SqlClient.SqlCommand();
Cmd.Connection = Con;

Cmd.CommandType =

CommandType.StoredProcedure;

try
{

Con.Open();

Cmd.CommandText =

"name";
Cmd.Parameters.Add(

"@UserName", SqlDbType.VarChar, 20);
Cmd.Parameters[

"@UserName"].Value = UserName;
Cmd.Parameters.Add(

"@Password", SqlDbType.VarChar, 20);
Cmd.Parameters[

"@Password"].Value = Password;
System.Data.SqlClient.

SqlDataReader reader = Cmd.ExecuteReader(CommandBehavior.CloseConnection);

if (reader.HasRows)
{


return true;
}


else
{


return false;
}

}


catch (Exception ex)
{


Console.WriteLine(ex.Message);

//Return False;
}


throw new Exception("The method or operation is not implemented.");
}

Welcome.aspx.cs (After user logs in he is redirected to this page)

protected

void Page_Load(object sender, EventArgs e)
{


MembershipUser CurrentUser = Membership.GetUser(true); [This gives me an error ]
Label1.Text = CurrentUser.UserName.ToString();

}



Thanks in Advance for your help. Best Regards

QuestionHow to get all the tables with their schema name in sql server 2005. Pin
NK722-Feb-07 19:56
NK722-Feb-07 19:56 
AnswerRe: How to get all the tables with their schema name in sql server 2005. Pin
Hesham Amin22-Feb-07 22:35
Hesham Amin22-Feb-07 22:35 
Questionstatic page user logon active directory Pin
mushy22-Feb-07 19:51
mushy22-Feb-07 19:51 
QuestionError! Pin
hiremath7122-Feb-07 19:46
hiremath7122-Feb-07 19:46 
AnswerRe: Error! Pin
__DanC__22-Feb-07 20:45
__DanC__22-Feb-07 20:45 
QuestionMINIMIZE TO MAXIMIZE Pin
M Riaz Bashir22-Feb-07 19:29
M Riaz Bashir22-Feb-07 19:29 
AnswerRe: MINIMIZE TO MAXIMIZE Pin
Stefan Troschuetz22-Feb-07 22:08
Stefan Troschuetz22-Feb-07 22:08 
GeneralRe: MINIMIZE TO MAXIMIZE Pin
M Riaz Bashir22-Feb-07 22:18
M Riaz Bashir22-Feb-07 22:18 
GeneralRe: MINIMIZE TO MAXIMIZE Pin
Stefan Troschuetz22-Feb-07 22:24
Stefan Troschuetz22-Feb-07 22:24 
QuestionConditional Operator in C# Pin
AesopTurtle22-Feb-07 19:21
AesopTurtle22-Feb-07 19:21 
AnswerRe: Conditional Operator in C# [modified] Pin
Tuwing.Sabado22-Feb-07 19:32
Tuwing.Sabado22-Feb-07 19:32 
GeneralRe: Conditional Operator in C# Pin
Harini N K22-Feb-07 19:41
Harini N K22-Feb-07 19:41 
GeneralRe: Conditional Operator in C# Pin
Tuwing.Sabado22-Feb-07 19:49
Tuwing.Sabado22-Feb-07 19:49 
GeneralRe: Conditional Operator in C# [modified] Pin
AesopTurtle22-Feb-07 19:52
AesopTurtle22-Feb-07 19:52 
GeneralRe: Conditional Operator in C# Pin
Tuwing.Sabado22-Feb-07 21:00
Tuwing.Sabado22-Feb-07 21:00 
GeneralRe: Conditional Operator in C# Pin
AesopTurtle22-Feb-07 21:21
AesopTurtle22-Feb-07 21:21 
GeneralRe: Conditional Operator in C# Pin
Harini N K22-Feb-07 21:21
Harini N K22-Feb-07 21:21 

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.