本文整理汇总了C#中System.Web.UI.WebControls.WebControl.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# WebControl.GetType方法的具体用法?C# WebControl.GetType怎么用?C# WebControl.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.WebControls.WebControl
的用法示例。
在下文中一共展示了WebControl.GetType方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: RegisterFromResource
public void RegisterFromResource(WebControl control, Type resourceType, string resourceNamePrefix, string resourceName)
{
var scriptManager = GetPageScriptManager(control);
if (ResourceAddedAlready(scriptManager, resourceName)) return;
var cssUrl = control.Page.ClientScript.GetWebResourceUrl(resourceType,
resourceNamePrefix + "." + resourceName);
var css = @"<link href=""" + cssUrl + @""" type=""text/css"" rel=""stylesheet"" />";
ScriptManager.RegisterClientScriptBlock(control.Page, control.GetType(), resourceName, css, false);
}
示例3: SetFollowing
/// <summary>
/// Configures a control to display and toggle following for the specified entity
/// </summary>
/// <param name="followEntity">The follow entity. NOTE: Make sure to use PersonAlias instead of Person when following a Person</param>
/// <param name="followControl">The follow control.</param>
/// <param name="follower">The follower.</param>
public static void SetFollowing( IEntity followEntity, WebControl followControl, Person follower )
{
var followingEntityType = EntityTypeCache.Read( followEntity.GetType() );
if ( follower != null && follower.PrimaryAliasId.HasValue )
{
using ( var rockContext = new RockContext() )
{
var personAliasService = new PersonAliasService( rockContext );
var followingService = new FollowingService( rockContext );
var followingQry = followingService.Queryable()
.Where( f =>
f.EntityTypeId == followingEntityType.Id &&
f.PersonAlias.PersonId == follower.Id );
followingQry = followingQry.Where( f => f.EntityId == followEntity.Id );
if ( followingQry.Any() )
{
followControl.AddCssClass( "following" );
}
else
{
followControl.RemoveCssClass( "following" );
}
}
int entityId = followEntity.Id;
// only show the following control if the entity has been saved to the database
followControl.Visible = entityId > 0;
string script = string.Format(
@"Rock.controls.followingsToggler.initialize($('#{0}'), {1}, {2}, {3}, {4});",
followControl.ClientID,
followingEntityType.Id,
entityId,
follower.Id,
follower.PrimaryAliasId );
ScriptManager.RegisterStartupScript( followControl, followControl.GetType(), "following", script, true );
}
}
示例4: RenderGVIEvents
internal List<string> RenderGVIEvents(WebControl PageControl)
{
List<string> eventsList = new List<string>();
System.Reflection.PropertyInfo[] props = PageControl.GetType().GetProperties();
foreach (System.Reflection.PropertyInfo prop in props)
{
GviEventOption option = prop.GetCustomAttributes(typeof(GviEventOption), false)
.Cast<GviEventOption>().FirstOrDefault();
if (option == null) continue;
object value = prop.GetValue(PageControl,null);
if ((value == null) || (string.IsNullOrEmpty(value.ToString()))) continue;
string foo = string.Format("google.visualization.events.addListener(chart, '{0}', chart.{1} = function(){{ {1}(chart); }});", option.EventName, value);
foo = foo.Replace(";;", ";");
eventsList.Add(foo);
}
return eventsList;
}
示例5: GetControlXml
/// <summary>
/// 取得Control对应的xml
/// </summary>
/// <param name="control">Control</param>
/// <param name="prop">绑定Control的属性</param>
/// <param name="field">绑定的字段</param>
/// <param name="format">绑定的格式</param>
/// <returns>xml</returns>
private string GetControlXml(WebControl control, PropertyInfo prop, string field, string format)
{
StringBuilder builder = new StringBuilder();
//builder.Append("<br/>");
if (control != null)
{
StringBuilder builderInnerHtml = new StringBuilder();
Type controltype = control.GetType();
//if (controltype.Namespace == "Srvtools")
//{
// builder.Append(string.Format("<{0}:{1} ID=\"{2}\" runat=\"server\" ", INFOLIGHTMARK, controltype.Name, control.ID));
//}
//else
//{
// builder.Append(string.Format("<{0}:{1} ID=\"{2}\" runat=\"server\" ", "Asp", controltype.Name, control.ID));
//}
if (controltype.Namespace == "Srvtools")
{
builder.Append(string.Format("<{0}:{1} runat=\"server\" ", INFOLIGHTMARK, controltype.Name));
}
else
{
builder.Append(string.Format("<{0}:{1} runat=\"server\" ", "JQTools", controltype.Name));
}
if (prop != null)
{
builder.Append(string.Format("{0}='<%# Bind(\"{1}\"", prop.Name, field, format));
if (!string.IsNullOrEmpty(format))
{
builder.Append(string.Format("{0}", format));
}
builder.Append(") %>' ");
}
//PropertyInfo[] infos = controltype.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly);
PropertyInfo[] infos = controltype.GetProperties();
List<String> listTemp = new List<string>();
for (int i = 0; i < infos.Length; i++)
{
if (infos[i].Name == "ValidateRequestMode")
continue;
if (prop == null || (prop != null && prop.Name != infos[i].Name))
{
if (listTemp.Contains(infos[i].Name))
continue;
listTemp.Add(infos[i].Name);
if (!IsVisibilityHidden(infos[i]))
{
if (infos[i].PropertyType == typeof(string) || infos[i].PropertyType == typeof(int) || infos[i].PropertyType == typeof(bool)
|| infos[i].PropertyType.BaseType == typeof(Enum))
{
object value = infos[i].GetValue(control, null);
object defaultvalue = GetDefaultValue(infos[i]);
if (infos[i].CanWrite && value != null && !String.IsNullOrEmpty(value.ToString())
&& value != defaultvalue && infos[i].Name != "Visible")
{
builder.Append(string.Format("{0}=\"{1}\" ", infos[i].Name, value));
}
}
else if (infos[i].PropertyType.Name == "JQCollection`1")
{
string collectionxml = GetCollectionXml(infos[i], (IJQProperty)infos[i].GetValue(control, null));
if (collectionxml.Length > 0)
{
builderInnerHtml.AppendLine(collectionxml);
}
}
}
}
}
builder.AppendLine(">");
builder.Append(builderInnerHtml.ToString());
if (controltype.Namespace == "Srvtools")
{
builder.AppendLine(string.Format("</{0}:{1}>", INFOLIGHTMARK, controltype.Name));
}
else
{
builder.AppendLine(string.Format("</{0}:{1}>", "JQTools", controltype.Name));
}
}
return builder.ToString();
}
示例6: InitializeDepartments
/// <summary>
/// PopulateDepartment by WebControl
/// </summary>
public static void InitializeDepartments(WebControl control, SqlDataSource DepartmentDataSource=null)
{
object Departments = null;
if (DepartmentDataSource != null)
{
Departments = DepartmentDataSource;
}
else
{
Departments = DepartmentManager.Departments();
}
switch(control.GetType().Name)
{
case "DropDownList":
DropDownList DDList = (DropDownList)control;
DDList.Items.Clear();
DDList.DataSource = Departments;
DDList.DataTextField = "DepartmentName";
DDList.DataValueField = "Id";
DDList.DataBind();
break;
case "GridView":
GridView gvDepartments = (GridView)control;
gvDepartments.DataSource = Departments;
gvDepartments.DataBind();
break;
case "ListBox":
ListBox ListBoxDepartments = (ListBox)control;
ListBoxDepartments.DataSource = Departments;
ListBoxDepartments.DataTextField = "DepartmentName";
ListBoxDepartments.DataValueField = "Id";
ListBoxDepartments.DataBind();
break;
case "CheckBoxList":
CheckBoxList chkBoxListDepartment = (CheckBoxList)control;
chkBoxListDepartment.DataSource = Departments;
chkBoxListDepartment.DataTextField = "DepartmentName";
chkBoxListDepartment.DataValueField = "Id";
chkBoxListDepartment.DataBind();
break;
}
}
示例7: GHTTestCommon_WebControl
/// <summary>
/// Common Tests of WebControl.
/// </summary>
protected void GHTTestCommon_WebControl(WebControl obj, string MemberName)
{
WebControl objNew;
bool bExceptionCaught = false;
MemberName = MemberName.ToLower();
//AccessKey
if (MemberName.CompareTo("AccessKey".ToLower())== 0)
{
//Press Alt-Y to get focus here
obj.AccessKey = ""; //empty is ok
obj.AccessKey = "Y";
objNew = (WebControl)GHTElementClone(obj.GetType());
// test Exceptions
try
{
objNew.AccessKey = "XX";
GHTActiveSubTest.Controls.Add(objNew);
}
catch (ArgumentException)
{
bExceptionCaught = true;
}
if (bExceptionCaught == true)
{
GHTSubTestAddResult(GHTActiveSubTest, MemberName + " ArgumentException OK");
}
bExceptionCaught = false;
}
//Attributes tested at System.Web.UI.AttributeCollection
//BackColor
if (MemberName.CompareTo("BackColor".ToLower())== 0)
{
obj.BackColor = System.Drawing.Color.AliceBlue;
objNew = (WebControl)GHTElementClone(obj.GetType());
objNew.BackColor = System.Drawing.Color.Magenta;
GHTActiveSubTest.Controls.Add(objNew);
}
//BorderColor
if (MemberName.CompareTo("BorderColor".ToLower())== 0)
{
objNew = (WebControl)GHTElementClone(obj.GetType());
objNew.BorderColor = System.Drawing.Color.AliceBlue;
GHTActiveSubTest.Controls.Add(objNew);
}
//BorderStyle
if (MemberName.CompareTo("BorderStyle".ToLower())== 0)
{
objNew = (WebControl)GHTElementClone(obj.GetType());
objNew.BorderStyle = System.Web.UI.WebControls.BorderStyle.Dotted;
GHTActiveSubTest.Controls.Add(objNew);
}
//BorderWidth
if (MemberName.CompareTo("BorderWidth".ToLower())== 0)
{
objNew = (WebControl)GHTElementClone(obj.GetType());
objNew.BorderWidth = 10;
GHTActiveSubTest.Controls.Add(objNew);
}
// ControlStyle
// ControlStyleCreated
//CssClass
if (MemberName.CompareTo("CssClass".ToLower())== 0)
{
objNew = (WebControl)GHTElementClone(obj.GetType());
objNew.CssClass = "zoobie";
GHTActiveSubTest.Controls.Add(objNew);
}
//Enabled
if (MemberName.CompareTo("Enabled".ToLower())== 0)
{
objNew = (WebControl)GHTElementClone(obj.GetType());
objNew.Enabled = true;
GHTActiveSubTest.Controls.Add(objNew);
}
//Font
if (MemberName.CompareTo("Font".ToLower())== 0)
{
GHTSubTestAddResult(GHTActiveSubTest, MemberName + " " + obj.Font.ToString());
}
//ForeColor
if (MemberName.CompareTo("ForeColor".ToLower())== 0)
{
objNew = (WebControl)GHTElementClone(obj.GetType());
objNew.ForeColor = System.Drawing.Color.Cornsilk;
//.........这里部分代码省略.........
示例8: GetControlXml
private string GetControlXml(WebControl control, PropertyInfo prop, string field, string format)
{
StringBuilder builder = new StringBuilder();
if (control != null)
{
StringBuilder builderInnerHtml = new StringBuilder();
Type controltype = control.GetType();
if (controltype.Namespace == "Srvtools")
{
builder.Append(string.Format("<{0}:{1} ID=\"{2}\" runat=\"server\" ", INFOLIGHTMARK, controltype.Name, control.ID));
}
else
{
builder.Append(string.Format("<{0}:{1} ID=\"{2}\" runat=\"server\" ", "Asp", controltype.Name, control.ID));
}
if (prop != null)
{
builder.Append(string.Format("{0}='<%# Bind(\"{1}\"", prop.Name, field));
if (!string.IsNullOrEmpty(format))
{
builder.Append(string.Format("{0}", FormatEditMask(format)));
}
builder.Append(") %>' ");
}
PropertyInfo[] infos = controltype.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly);
for (int i = 0; i < infos.Length; i++)
{
if (prop == null || (prop != null && prop.Name != infos[i].Name))
{
if (!IsVisibilityHidden(infos[i]))
{
if (infos[i].PropertyType == typeof(string) || infos[i].PropertyType == typeof(int) || infos[i].PropertyType == typeof(bool)
|| infos[i].PropertyType.BaseType == typeof(Enum))
{
object value = infos[i].GetValue(control, null);
object defaultvalue = GetDefaultValue(infos[i]);
if (infos[i].CanWrite && value != defaultvalue)
{
builder.Append(string.Format("{0}=\"{1}\" ", infos[i].Name, value));
}
}
else if (infos[i].PropertyType.BaseType == typeof(InfoOwnerCollection))
{
string collectionxml = GetCollectionXml(infos[i], (InfoOwnerCollection)infos[i].GetValue(control, null));
if (collectionxml.Length > 0)
{
builderInnerHtml.AppendLine(collectionxml);
}
}
}
}
}
builder.AppendLine(">");
builder.Append(builderInnerHtml.ToString());
if (controltype.Namespace == "Srvtools")
{
builder.AppendLine(string.Format("</{0}:{1}>", INFOLIGHTMARK, controltype.Name));
}
else
{
builder.AppendLine(string.Format("</{0}:{1}>", "Asp", controltype.Name));
}
}
return builder.ToString();
}
示例9: GetControlValue
private static string GetControlValue(WebControl ctrl)
{
RadInputControl txt = ctrl as RadInputControl;
if (null != txt)
return txt.Text;
throw new NotSupportedException(ctrl.GetType().Name);
}