Hi,
I am using a login control and am having issues with Firefox wanting to display a username <asp:LoginName ID="HeadLoginName" in my LoggedInTemplate (which will always be an email address) as a mailto: element. IE renders it as just text with my css styles.
http://img338.imageshack.us/img338/7276/loginview.jpg[
^]
How can I prevent Firefox from rendering the username as an email address? Or, how can I truncate the displayed user name (everything including and after the @) using substring() and IndexOf() embedded in the aspx page?
I have tried:
protected void Page_Load(object sender, EventArgs e)
{
string username = this.User.Identity.Name;
username = changeTheName(username);
HeadLoginName.FormatString = "Welcome, " + username;
}
private string changeTheName(string username)
{
return username.Substring(0, username.IndexOf('@'));
}
but the .cs file does not know the HeadLoginName control exists.
C:\Web\Site.Master.cs(13,32): error CS1061: 'SiteMaster' does not contain a definition for 'User' and no extension method 'User' accepting a first argument of type 'SiteMaster' could be found (are you missing a using directive or an assembly reference?)
C:\Web\Site.Master.cs(15,9): error CS0103: The name 'HeadLoginName' does not exist in the current context
My problem seems to be that I cannot access the HeadLoginName control from the Page_Load .cs file (Site.Master).
<<<<<<<<<<UPDATE>>>>>>>>>>
This is what I found to work:
protected void Page_Load(object sender, EventArgs e)
{
string username = HttpContext.Current.User.Identity.Name;
username = changeTheName(username);
LoginName loginName = HeadLoginView.FindControl("HeadLoginName") as LoginName;
if(loginName != null)
loginName.FormatString = "Welcome, " + username;
}
private string changeTheName(string username)
{
return username.Substring(0, username.IndexOf('@'));
}
Thanks.