1.loginview控件为什么会链接到login.aspx? 可以修改链接目的地址吗?
2.书上说编辑loginview控件时,可以通过如下获得登陆的用户名:
<RoleGroups>
  <asp:RoleGroup Roles="Administrators">
     <ContentTemplate>
        <asp:LoginName ID="LoginName2" runat="server" FormatString="You are logged in as <b>{0}</b>" CssClass="UserInfoText" />
......我想问的是为什么用{0}就可以获得用户名?这个用户名是需要一个login控件传递过来的吗?

解决方案 »

  1.   

    loginview控件为什么会链接到login.aspx? 可以修改链接目的地址吗?在web.config中配置
      

  2.   

    <asp:LoginName
    这个是微软提供的专门的控件,可以反射看一下他是用identity.Name来替换{0}的
      

  3.   

    protected internal override void RenderContents(HtmlTextWriter writer)
    {
        string userName = this.UserName;
        if (!string.IsNullOrEmpty(userName))
        {
            userName = HttpUtility.HtmlEncode(userName);
            string format = this.FormatString;
            if (format.Length == 0)
            {
                writer.Write(userName);
            }
            else
            {
                try
                {
                    writer.Write(string.Format(CultureInfo.CurrentCulture, format, new object[] { userName }));
                }
                catch (FormatException exception)
                {
                    throw new FormatException(SR.GetString("LoginName_InvalidFormatString"), exception);
                }
            }
        }

      

  4.   

    1 web.config
    2 应该从User.Name获得 填充的
    这些控件 其实都没啥用 学的越多 陷得越深