本文整理汇总了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");
//.........这里部分代码省略.........