本文整理汇总了C#中System.Web.UI.UserControl类的典型用法代码示例。如果您正苦于以下问题:C# UserControl类的具体用法?C# UserControl怎么用?C# UserControl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UserControl类属于System.Web.UI命名空间,在下文中一共展示了UserControl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RegisterInitializationScripts
public void RegisterInitializationScripts(UserControl control, params string[] scripts)
{
var key = control.GetType().BaseType.Name;
if (_initializationLines.ContainsKey(key))
return;
_initializationLines.Add(key, scripts.ToSeparatedString("\r\n"));
}
示例2: PopupAggiungiEccezione_AggiungiButtonClicked
private void PopupAggiungiEccezione_AggiungiButtonClicked(object sender, UserControl.RagioniSocialiCorrelate.AggiungiEccezioneEventArgs e)
{
try
{
string err = proxyMtd.InsertDealerImport(e.Codice);
if (err == "")
{
DealerTable = proxyMtd.GetAllDealerImport();
eccImportGridView.DataSource = DealerTable;
eccImportGridView.DataBind();
importUpdatePanel.Update();
PopupAggiungiEccezione.Hide();
}
else
{
PopupAggiungiEccezione.setErrorMessage("Codice esistente!");
}
}
catch (Exception ex)
{
PopupMessaggio.ShowMsgBox(ex.Message, true);
}
}
示例3: PodlaczDoBazy
public PodlaczDoBazy(UserControl l)
{
login = l;
ConnStr = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + HttpRuntime.AppDomainAppPath + @"\App_Data\Database_Ankiety.accdb;Jet OLEDB:Database Password=";
MyConn = new OleDbConnection(ConnStr);
}
示例4: GetPortalModuleBase
/// <Summary>
/// GetPortalModuleBase gets the parent PortalModuleBase Control
/// </Summary>
public static PortalModuleBase GetPortalModuleBase( UserControl objControl )
{
PortalModuleBase objPortalModuleBase = null;
Panel ctlPanel;
if (objControl is SkinObjectBase)
{
ctlPanel = (Panel)objControl.Parent.FindControl("ModuleContent");
}
else
{
ctlPanel = (Panel)objControl.FindControl("ModuleContent");
}
if (ctlPanel != null)
{
try
{
objPortalModuleBase = (PortalModuleBase)ctlPanel.Controls[0];
}
catch
{
// module was not loaded correctly
}
}
if (objPortalModuleBase == null)
{
objPortalModuleBase = new PortalModuleBase();
objPortalModuleBase.ModuleConfiguration = new ModuleInfo();
}
return objPortalModuleBase;
}
示例5: LoadControlFromVirtualPath
/// <summary>
/// Load a webforms view (Page, UserControl, MasterPage) from the given virtual path.
/// </summary>
/// <param name="virtualPath"></param>
/// <returns></returns>
public static Control LoadControlFromVirtualPath(string virtualPath)
{
// We're using LoadControl of an arbitrary UserControl to load the view. We could also use the BuildManager, but
// in that case, the control hierarchy appears to be empty and thus, pretty useless.
UserControl controlLoader = new UserControl();
return controlLoader.LoadControl(virtualPath);
}
示例6: Properties_Deny_Unrestricted
public void Properties_Deny_Unrestricted ()
{
UserControl uc = new UserControl ();
try {
Assert.IsNull (uc.Application, "Application");
}
catch (NullReferenceException) {
// ms 2.0 rc
}
Assert.IsNotNull (uc.Attributes, "Attributes");
try {
Assert.IsNull (uc.Cache, "Cache");
}
catch (NullReferenceException) {
// ms 2.0 rc
}
try {
Assert.IsFalse (uc.IsPostBack, "IsPostBack");
}
catch (NullReferenceException) {
// ms 2.0 rc
}
try {
Assert.IsNull (uc.Request, "Request");
}
catch (NullReferenceException) {
// ms 2.0 rc
}
try {
Assert.IsNull (uc.Response, "Response");
}
catch (NullReferenceException) {
// ms 2.0 rc
}
try {
Assert.IsNull (uc.Server, "Server");
}
catch (NullReferenceException) {
// ms 2.0 rc
}
try {
Assert.IsNull (uc.Session, "Session");
}
catch (NullReferenceException) {
// ms 2.0 rc
}
try {
Assert.IsNull (uc.Trace, "Trace");
}
catch (NullReferenceException) {
// ms 2.0 rc
}
try {
Assert.IsNotNull (uc.CachePolicy, "CachePolicy");
}
catch (NotImplementedException) {
// mono
}
}
示例7: PodlaczDoBazy
public PodlaczDoBazy(UserControl l)
{
login = l;
// ConnStr = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + HttpRuntime.AppDomainAppPath + @"\App_Data\Database_Ankiety.accdb;Jet OLEDB:Database Password=";
// ConnStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=(LocalDB)\v11.0;AttachDbFilename=\"C:\\Users\\Użytkownik\\Desktop\\Ankiety v2\\Ankiety v2\\App_Data\\BazaDanychV2.mdf\";Integrated Security=True;Connect Timeout=30";
// MyConn = new OleDbConnection(ConnStr);
}
示例8: RegisterStartUpScript
/// <summary>
/// Registers a script near the end of the form only allowed to register Js scripts.
/// </summary>
/// <param name="control">The control.</param>
/// <param name="scriptName">Name of the script.</param>
/// <param name="script">The script.</param>
/// <param name="minimized">if set to <c>true</c> [minimized].</param>
public void RegisterStartUpScript(UserControl control, string scriptName, string script, bool minimized = false)
{
Contract.Requires(control != null);
if (minimized)
{
script = this.MinimizeJsCode(script);
}
control.Page.ClientScript.RegisterStartupScript(control.GetType(), scriptName,
string.Format("<script>{0}</script>", script));
}
示例9: SetPropertyValues
public static void SetPropertyValues(UserControl control, HttpContext context)
{
var metadata = GetMetadata(control.GetType());
foreach (var property in metadata.Keys)
{
object value = GetValue(metadata[property], context) ?? GetDefaultValue(property);
if (value != null)
{
property.SetValue(control, Convert.ChangeType(value, property.PropertyType), null);
}
}
}
示例10: RenderControl
private string RenderControl(UserControl control)
{
StringBuilder sb = new StringBuilder();
// Render the control into the stringbuilder
StringWriter sw = new StringWriter( sb );
Html32TextWriter htw = new Html32TextWriter( sw );
control.RenderControl( htw );
// Get full body text
return sb.ToString();
}
示例11: GetPlaceholderKeyName
/// <summary>
/// Gets the name of the placeholder key that the passed in sublayout is bound to. This will return an empty string
/// if for some reason we cannot get the placeholder name.
///
/// You would use this from the code behind of a sublayout. So for example if I had a sublayout sltList and
/// I wanted to know what placeholder it was bound to I would have something this in the code behind
/// "string plcKeyName = PresentationUtil.GetPlaceholderKeyName(this);"
/// </summary>
/// <param name = "sublayout">The sublayout.</param>
/// <returns></returns>
public static string GetPlaceholderKeyName(UserControl sublayout)
{
if (sublayout == null) return string.Empty;
if (sublayout.Parent == null) return string.Empty;
if (sublayout.Parent.Parent == null) return string.Empty;
//Make sure my grandparent is a placeholder, if not return an empty string
if (typeof (Placeholder) != sublayout.Parent.Parent.GetType()) return string.Empty;
//The placeholder is my grandparent, so cast it and get the key value
Placeholder grandParent = (Placeholder) sublayout.Parent.Parent;
return grandParent.Key;
}
示例12: AddControlToBody_WithOtherControl_AddsControlToBodyControl
public void AddControlToBody_WithOtherControl_AddsControlToBodyControl()
{
// arrange
var updatePanel = new UpdatePanel();
var control = new UserControl();
var bodyControl = new UserControl();
var page = new SubtextMasterPage();
// act
page.AddControlToBody("Other", control, updatePanel, bodyControl);
// assert
Assert.AreEqual(control, bodyControl.Controls[0]);
}
示例13: LoadControl_WithControlName_ReplacesDotWithUnderscoreInId
public void LoadControl_WithControlName_ReplacesDotWithUnderscoreInId()
{
// arrange
var containerControl = new Mock<IContainerControl>();
var loadedControl = new UserControl {ID = "Foo.Bar"};
containerControl.Setup(tc => tc.LoadControl("~/Skins/OfMyChinnyChinChin/Controls/ViewPost.ascx")).Returns(loadedControl);
var skin = new SkinConfig { TemplateFolder = "OfMyChinnyChinChin" };
var skinControlLoader = new SkinControlLoader(containerControl.Object, skin);
// act
var control = skinControlLoader.LoadControl("ViewPost");
// assert
Assert.AreEqual("Foo_Bar", control.ID);
}
示例14: LoadControl_WithControlName_LoadsTheControlFromTheSkinFolder
public void LoadControl_WithControlName_LoadsTheControlFromTheSkinFolder()
{
// arrange
var containerControl = new Mock<IContainerControl>();
var loadedControl = new UserControl { ID = "Foo.Bar" };
containerControl.Setup(tc => tc.LoadControl("~/Skins/OfMyChinnyChinChin/Controls/ViewPost.ascx")).Returns(loadedControl);
var skin = new SkinConfig {TemplateFolder = "OfMyChinnyChinChin"};
var skinControlLoader = new SkinControlLoader(containerControl.Object, skin);
// act
var control = skinControlLoader.LoadControl("ViewPost");
// assert
Assert.AreSame(loadedControl, control);
}
示例15: AddControlToBody_WithComments_AddsControlToUpdatePanel
public void AddControlToBody_WithComments_AddsControlToUpdatePanel()
{
// arrange
var updatePanel = new UpdatePanel();
var control = new UserControl {Visible = false};
var bodyControl = new UserControl();
var page = new SubtextMasterPage();
// act
page.AddControlToBody("Comments", control, updatePanel, bodyControl);
// assert
Assert.AreEqual(control, updatePanel.ContentTemplateContainer.Controls[0]);
Assert.IsTrue(control.Visible);
}