本文整理汇总了C#中System.Web.UI.WebControls.WebControl类的典型用法代码示例。如果您正苦于以下问题:C# WebControl类的具体用法?C# WebControl怎么用?C# WebControl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WebControl类属于System.Web.UI.WebControls命名空间,在下文中一共展示了WebControl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetUpEmployeesView
public static void SetUpEmployeesView(WebControl control, string title)
{
ASPxNavBar navBar = (ASPxNavBar)control;
NavBarGroup employeesGroup = navBar.Groups.First();
employeesGroup.Items.Clear();
employeesGroup.Text = title;
}
示例2: AutoFillExtender
public AutoFillExtender(AutoFillExtenderXml xml, WebControl target)
{
_targetControl = target;
_type = xml.Type;
_filterId = xml.FilterId;
this.Name = xml.Name;
}
示例3: StyleControl
private static void StyleControl(WebControl control)
{
if (control == null || control is TableCell || control is LinkButton) return;
if (control is Label) control.CssClass.Toggle("ErrorLabel", "{0} {1}");
else control.CssClass.Toggle("ErrorItem", "{0} {1}");
}
示例4: AddAttributesToRender
public sealed override void AddAttributesToRender(HtmlTextWriter writer, WebControl owner)
{
string cssClass = string.Empty;
bool flag = true;
if (this._owner.IsSet(2))
{
cssClass = this._owner.CssClass;
}
if (base.RegisteredCssClass.Length != 0)
{
flag = false;
if (cssClass.Length != 0)
{
cssClass = cssClass + " " + base.RegisteredCssClass;
}
else
{
cssClass = base.RegisteredCssClass;
}
}
if (cssClass.Length > 0)
{
writer.AddAttribute(HtmlTextWriterAttribute.Class, cssClass);
}
if (flag)
{
base.GetStyleAttributes(owner).Render(writer);
}
}
示例5: makeCell
public static WebControl makeCell(Directory directory)
{
WebControl td = new WebControl(HtmlTextWriterTag.Td);
//td.BorderWidth = Unit.Pixel(1);
td.Style.Add(HtmlTextWriterStyle.Padding, "1em");
td.Style.Add(HtmlTextWriterStyle.VerticalAlign, "top");
td.CssClass += "vcard";
Panel textPanel = new Panel();
textPanel.Style.Add("float", "left");
Panel namePanel = new Panel();
namePanel.CssClass += "n ";
namePanel.CssClass += "fn ";
namePanel.Controls.Add(makeLastName(directory));
namePanel.Controls.Add(makeFirstNames(directory));
textPanel.Controls.Add(namePanel);
textPanel.Controls.Add(makeAddress(directory));
textPanel.Controls.Add(makeGeneralEmails(directory));
textPanel.Controls.Add(makePersonEmails(directory));
textPanel.Controls.Add(makeGeneralPhones(directory));
textPanel.Controls.Add(makePersonPhones(directory));
td.Controls.Add(textPanel);
if (directory.photo != null && directory.photo.Id != null && directory.photo.PicasaEntry != null)
{
Panel picturePanel = new Panel();
picturePanel.Style.Add("float", "right");
picturePanel.Controls.Add(makeGeneralPhoto(directory));
td.Controls.Add(picturePanel);
}
return td;
}
示例6: AddAttributesToRender
public override void AddAttributesToRender(HtmlTextWriter writer, WebControl owner)
{
base.AddAttributesToRender(writer, owner);
if (!this.Wrap)
{
if (this.IsControlEnableLegacyRendering(owner))
{
writer.AddAttribute(HtmlTextWriterAttribute.Nowrap, "nowrap");
}
else
{
writer.AddStyleAttribute(HtmlTextWriterStyle.WhiteSpace, "nowrap");
}
}
System.Web.UI.WebControls.HorizontalAlign horizontalAlign = this.HorizontalAlign;
if (horizontalAlign != System.Web.UI.WebControls.HorizontalAlign.NotSet)
{
TypeConverter converter = TypeDescriptor.GetConverter(typeof(System.Web.UI.WebControls.HorizontalAlign));
writer.AddAttribute(HtmlTextWriterAttribute.Align, converter.ConvertToString(horizontalAlign).ToLower(CultureInfo.InvariantCulture));
}
System.Web.UI.WebControls.VerticalAlign verticalAlign = this.VerticalAlign;
if (verticalAlign != System.Web.UI.WebControls.VerticalAlign.NotSet)
{
TypeConverter converter2 = TypeDescriptor.GetConverter(typeof(System.Web.UI.WebControls.VerticalAlign));
writer.AddAttribute(HtmlTextWriterAttribute.Valign, converter2.ConvertToString(verticalAlign).ToLower(CultureInfo.InvariantCulture));
}
}
示例7: addStyleSheet
public static void addStyleSheet(string css, string key, Page currentPage, WebControl control)
{
ControlCollection ctrls = currentPage.Controls;
if (currentPage.Master != null)
ctrls = currentPage.Master.Controls;
foreach (Control ctrl in ctrls)
{
if (ctrl.GetType().Name == "HtmlHead")
{
ctrls = ctrl.Controls;
break;
}
}
if (key != null)
{
foreach (Control ctrl in ctrls)
{
if (ctrl.ID == key)
return;
}
}
string url = currentPage.ClientScript.GetWebResourceUrl(control.GetType(), "ESWCtrls.ResEmbed.Styles." + css);
HtmlLink link = new HtmlLink();
link.Attributes.Add("type", "text/css");
link.Attributes.Add("rel", "stylesheet");
link.Attributes.Add("media", "screen");
link.Href = url;
link.ID = key;
ctrls.Add(new LiteralControl("\n"));
ctrls.Add(link);
}
示例8: TryEnable
bool TryEnable(WebControl c, bool enabled)
{
if (c == null || c is Button)
return false;
c.Enabled = enabled;
return true;
}
示例9: SetSelector
/// <summary>
/// 設置Selector
/// </summary>
/// <param name="ctrlTrigger">控件ID--按鈕</param>
/// <param name="ctrlCode">控件ID--文本框1</param>
/// <param name="ctrlName">控件ID--文本框2</param>
public void SetSelector(WebControl ctrlTrigger, Control ctrlCode, Control ctrlName)
{
if (ctrlCode is TextBox) { (ctrlCode as TextBox).Attributes.Add("readonly", "readonly"); }
if (ctrlName is TextBox) { (ctrlName as TextBox).Attributes.Add("readonly", "readonly"); }
ctrlTrigger.Attributes.Add("onclick", string.Format("return setSelector('{0}','{1}','{2}')",
ctrlCode.ClientID, ctrlName.ClientID, Request.QueryString["modulecode"]));
}
示例10: RenderRepeater
// What is baseControl for ?
public void RenderRepeater (HtmlTextWriter w, IRepeatInfoUser user, Style controlStyle, WebControl baseControl)
{
PrintValues (user);
RepeatLayout layout = RepeatLayout;
bool listLayout = layout == RepeatLayout.OrderedList || layout == RepeatLayout.UnorderedList;
if (listLayout) {
if (user != null) {
if ((user.HasHeader || user.HasFooter || user.HasSeparators))
throw new InvalidOperationException ("The UnorderedList and OrderedList layouts do not support headers, footers or separators.");
}
if (OuterTableImplied)
throw new InvalidOperationException ("The UnorderedList and OrderedList layouts do not support implied outer tables.");
int cols = RepeatColumns;
if (cols > 1)
throw new InvalidOperationException ("The UnorderedList and OrderedList layouts do not support multi-column layouts.");
}
if (RepeatDirection == RepeatDirection.Vertical) {
if (listLayout)
RenderList (w, user, controlStyle, baseControl);
else
RenderVert (w, user, controlStyle, baseControl);
} else {
if (listLayout)
throw new InvalidOperationException ("The UnorderedList and OrderedList layouts only support vertical layout.");
RenderHoriz (w, user, controlStyle, baseControl);
}
}
示例11: Save
//protected static string ReadCss()
//{
// string res;
// string fileName = string.Format("table.css");
// string path = Path.Combine(HttpRuntime.AppDomainAppPath, @"App_Themes\Default\" + fileName);
// using (StreamReader s = new StreamReader(path))
// {
// res = s.ReadToEnd();
// }
// return res;
//}
public static bool Save(WebControl grid, string path)
{
try
{
using (StreamWriter s = new StreamWriter(path, false, Encoding.Unicode))
{
Page page = new Page();
page.EnableViewState = false;
HtmlForm frm = new HtmlForm();
frm.Attributes["runat"] = "server";
page.Controls.Add(frm);
frm.Controls.Add(grid);
StringWriter stringWrite = new StringWriter();
HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
frm.RenderControl(htmlWrite);
string start = @"<style>.text { mso-number-format:\@; }</style>";
s.Write(start);
s.Write(stringWrite.ToString());
}
return true;
}
catch
{
throw;
}
}
示例12: SetSelector
/// <summary>
/// 設置Selector
/// </summary>
/// <param name="ctrlTrigger">控件ID--按鈕</param>
/// <param name="ctrlCode">控件ID--文本框1</param>
/// <param name="ctrlName">控件ID--文本框2</param>
/// <param name="flag">Selector區分標誌</param>
public void SetSelector(WebControl ctrlTrigger, Control ctrlCode, Control ctrlName, string flag, string moduleCode)
{
if (ctrlCode is TextBox) { (ctrlCode as TextBox).Attributes.Add("readonly", "readonly"); }
if (ctrlName is TextBox) { (ctrlName as TextBox).Attributes.Add("readonly", "readonly"); }
ctrlTrigger.Attributes.Add("onclick", string.Format("return setSelector('{0}','{1}','{2}','{3}')",
ctrlCode.ClientID, ctrlName.ClientID, flag, moduleCode));
}
示例13: AppendCssClass
/// <summary>
/// Appends a CSS class to a control.
/// </summary>
/// <param name="control">The control.</param>
/// <param name="newClass">The new class.</param>
public static void AppendCssClass(WebControl control, string newClass)
{
if (control == null)
throw new ArgumentNullException("control", "Cannot add a css class to a null control");
if (newClass == null)
throw new ArgumentNullException("newClass", "Cannot add a null css class to a control");
string existingClasses = control.CssClass;
if (String.IsNullOrEmpty(existingClasses))
{
control.CssClass = newClass;
return;
}
string[] classes = existingClasses.Split(' ');
foreach (string attributeValue in classes)
{
if (String.Equals(attributeValue, newClass, StringComparison.Ordinal))
{
//value's already in there.
return;
}
}
control.CssClass += " " + newClass;
}
示例14: BuildContentsControl
private static WebControl BuildContentsControl(BlogEntry entry)
{
Panel contentsControl = new Panel();
WebControl textControl = new WebControl(HtmlTextWriterTag.P);
textControl.Controls.Add(new LiteralControl(entry.Content));
contentsControl.Controls.Add(textControl);
if (entry.Enclosure != null && entry.Enclosure.Uri != null)
{
HtmlGenericControl audio = new HtmlGenericControl("audio");
audio.Attributes.Add("controls", "controls");
audio.Attributes.Add("src", entry.Enclosure.Uri);
audio.Attributes.Add("type", "audio/mp3");
WebControl musicPlayer = new WebControl(HtmlTextWriterTag.Embed);
musicPlayer.ID = "musicPlayer_" + entry.id;
musicPlayer.Style.Add(HtmlTextWriterStyle.Width, "400px");
musicPlayer.Style.Add(HtmlTextWriterStyle.Height, "27px");
musicPlayer.Style.Add("border", "1px solid rgb(170, 170, 170)");
musicPlayer.Attributes.Add("src", "http://www.google.com/reader/ui/3523697345-audio-player.swf");
musicPlayer.Attributes.Add("flashvars", "audioUrl=" + entry.Enclosure.Uri);
musicPlayer.Attributes.Add("pluginspage", "http://www.macromedia.com/go/getflashplayer");
audio.Controls.Add(musicPlayer);
contentsControl.Controls.Add(audio);
}
return contentsControl;
}
示例15: AddAttributesToRender
public sealed override void AddAttributesToRender(HtmlTextWriter writer, WebControl owner) {
string cssClass = String.Empty;
bool renderInlineStyle = true;
if (_owner.IsSet(PROP_CSSCLASS)) {
cssClass = _owner.CssClass;
}
if (RegisteredCssClass.Length != 0) {
renderInlineStyle = false;
if (cssClass.Length != 0) {
cssClass = cssClass + " " + RegisteredCssClass;
}
else {
cssClass = RegisteredCssClass;
}
}
if (cssClass.Length > 0) {
writer.AddAttribute(HtmlTextWriterAttribute.Class, cssClass);
}
if (renderInlineStyle) {
CssStyleCollection styleAttributes = GetStyleAttributes(owner);
styleAttributes.Render(writer);
}
}