与Firefox和IE一起使用时在ASP.NET中呈现LoginView时出现问题 [英] Problem using with Firefox vs IE rendering LoginView in ASP.NET

查看:55
本文介绍了与Firefox和IE一起使用时在ASP.NET中呈现LoginView时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在使用登录控件,并且Firefox出现问题,希望在我的LoggedInTemplate(将始终是电子邮件地址)中显示用户名< asp:LoginName ID ="HeadLoginName"作为mailto:元素. IE将其呈现为具有CSS样式的纯文本.

http://img338.imageshack.us/img338/7276/loginview.jpg [ ^ ]

如何防止Firefox将用户名呈现为电子邮件地址?或者,如何使用嵌入在aspx页面中的substring()和IndexOf()截断显示的用户名(包括@之后的所有内容)?


我试过了:

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)
{
    //make changes:
    return username.Substring(0, username.IndexOf('@'));
}



但是.cs文件不知道HeadLoginName控件存在.

C:\ Web \ Site.Master.cs(13,32):错误CS1061:"SiteMaster"不包含"User"的定义,并且没有扩展方法"User"接受第一个类型的参数可以找到"SiteMaster"(您是否缺少using指令或程序集引用?)
C:\ Web \ Site.Master.cs(15,9):错误CS0103:名称"HeadLoginName"在当前上下文中不存在


我的问题似乎是我无法从Page_Load .cs文件(Site.Master)访问HeadLoginName控件.


<<<<<<<<<<<>>>>>>>><>>>>>< 我发现这是可行的:



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)
{
    //make changes:
    return username.Substring(0, username.IndexOf('@'));
}



谢谢.



Thanks.

推荐答案

负责显示用户名的控件是< asp:loginname runat ="server" id ="HeadLoginName/>< br mode ="hold ="/>< br mode ="which ="意味着=""that =""it ="显示=""the ="用户名=""mode =" hold"xmlns: asp =#unknown">您可以在服务器端分配此属性.

The control that is responsible for displaying the user name is <asp:loginname runat="server" id="HeadLoginName /><br mode=" hold=" /><br mode=" which="" means="" that="" it="" displays="" the="" username="" mode="hold" xmlns:asp="#unknown">You can assign this property on your server side.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
namespace CodeProjectWeb
{
    public partial class mypage: System.Web.UI.Page
    {
        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)
        {
            //make your changes:
            return "username changed";
        }
    }


}
祝你好运.


}
Good luck.


只是一个疯狂的猜测:

难道是您安装了某种Firefox附加组件,该附加组件使电子邮件地址和纯文本链接都可以单击?

干杯
Uwe
Just a wild guess:

Could it be that you installed some kind of Firefox Add-on that makes e-mail addresses and links in plain text clickable?

Cheers
Uwe


这篇关于与Firefox和IE一起使用时在ASP.NET中呈现LoginView时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆