当前位置: 首页>>代码示例>>C#>>正文


C# HtmlGenericControl.GetControlHtml方法代码示例

本文整理汇总了C#中System.Web.UI.HtmlControls.HtmlGenericControl.GetControlHtml方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlGenericControl.GetControlHtml方法的具体用法?C# HtmlGenericControl.GetControlHtml怎么用?C# HtmlGenericControl.GetControlHtml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.UI.HtmlControls.HtmlGenericControl的用法示例。


在下文中一共展示了HtmlGenericControl.GetControlHtml方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetUsersPresenceHtml

        /// <summary>
        /// 得到当前显示用户状态的Html
        /// </summary>
        /// <param name="userID">用户ID</param>
        /// <param name="userName">用户的显示名称</param>
        /// <param name="uniqueID"></param>
        /// <param name="showStatusImage">是否显示状态图标</param>
        /// <param name="showUserIcon">是否显示用户图标</param>
        /// <param name="showUserName">是否显示用户名称</param>
        /// <param name="statusImageType">状态图片类型</param>
        /// <param name="userIconUrl">用户图片路径</param>
        /// <param name="uiec">用户扩展信息的结构</param>
        /// <returns></returns>
        public static string GetUsersPresenceHtml(string userID, string userName, string uniqueID, bool showStatusImage,
            bool showUserIcon, bool showUserName, StatusImageType statusImageType, string userIconUrl, UserIMAddressCollection uiec, bool accountDisabled = false)
        {
            StringBuilder strB = new StringBuilder();

            if (string.IsNullOrEmpty(userID) == false)
            {
                if (showStatusImage)
                {
                    HtmlGenericControl imageDiv = new HtmlGenericControl("div");
                    //imageDiv.Style["position"] = "relative";

                    var userIconContainerCss = "";
                    var userIconCss = "";
                    if (statusImageType == StatusImageType.Ball)
                    {
                        imageDiv.Attributes["class"] = "uc-ball";
                    }
                    else if (statusImageType == StatusImageType.ShortBar)
                    {
                        imageDiv.Attributes["class"] = "uc-bar36";
                        userIconContainerCss = "uc-user-container-short";
                        userIconCss = "icon";
                    }
                    else if (statusImageType == StatusImageType.LongBar)
                    {
                        imageDiv.Attributes["class"] = "uc-bar52";
                        userIconContainerCss = "uc-user-container-long";
                        userIconCss = "icon";
                    }

                    HtmlImage image = new HtmlImage();
                    image.Src = ControlResources.UCStatusUrl;

                    if (accountDisabled)
                    {
                        image.Alt = Translator.Translate(Define.DefaultCulture, "用户账号禁用");
                        image.Attributes["class"] = "uc-blocked"; //禁用
                    }
                    else
                    {
                        image.Alt = Translator.Translate(Define.DefaultCulture, "无联机状态信息");
                        image.Attributes["class"] = "uc-hdr"; //默认
                        image.Attributes["ShowOfflinePawn"] = "true";
                        UserIMAddress extendInfo = uiec.Find(uie => uie.UserID == userID);

                        if (extendInfo != null)
                            image.Attributes["data-sip"] = NormalizeIMAddress(extendInfo.IMAddress);

                        image.ID = string.Format("{0},type=sip", uniqueID);
                        image.Attributes["name"] = "imnmark";
                    }

                    imageDiv.Controls.Add(image);

                    strB.Append(imageDiv.GetControlHtml());

                    if (showUserIcon)
                    {
                        HtmlGenericControl userIconDiv = new HtmlGenericControl("div");
                        //userIconDiv.Style["position"] = "relative";
                        userIconDiv.Attributes["class"] = userIconContainerCss;

                        var subDiv = new HtmlGenericControl("div");
                        subDiv.Attributes["class"] = userIconCss;

                        var img = new HtmlImage();
                        img.Src = userIconUrl;
                        img.Border = 0;

                        subDiv.Controls.Add(img);
                        userIconDiv.Controls.Add(subDiv);
                        if (showUserName)
                        {
                            HtmlGenericControl nameSpan = new HtmlGenericControl("span");
                            nameSpan.InnerText = userName;
                            userIconDiv.Controls.Add(nameSpan);
                        }
                        //nameSpan.Attributes["class"] = "imnStatusText";

                        strB.Append(userIconDiv.GetControlHtml());
                    }
                }

                if (statusImageType == StatusImageType.Ball && showUserName)
                {
                    HtmlGenericControl span = new HtmlGenericControl("span");
//.........这里部分代码省略.........
开发者ID:jerryshi2007,项目名称:AK47Source,代码行数:101,代码来源:UserPresence.cs


注:本文中的System.Web.UI.HtmlControls.HtmlGenericControl.GetControlHtml方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。