當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。