private void IterateOverChildControls(System.Web.UI.UserControl eFormUserControl, Control eFormControl, string dataElement, string nodeType, List <string> loadedControlNames, XmlNode controlNode) { foreach (Control con in eFormControl.Controls) { if (con is IEformInputField) { if (nodeType.Equals("table")) // we are looking for a table name match { if (((IEformInputField)con).Table != null) { string nodeName = ((IEformInputField)con).Table; if (nodeName.Equals(dataElement)) { // 3. if (!holder.Controls.Contains(eFormUserControl) && (!loadedControlNames.Contains(controlNode.Attributes["controlName"].Value))) { holder.Controls.Add(eFormUserControl); loadedControlNames.Add(controlNode.Attributes["controlName"].Value); } // now we want to highlight the entire row if this is the one the user selected if (((IEformInputField)con).RecordId != null) { string recordId = ((IEformInputField)con).RecordId; if (recordId.Equals(_recordId)) { // highlight it base.SetInvalidStyle(con, "e7d1c8"); } } } } } else // we are looking for a field name { if (((IEformInputField)con).Field != null) { string nodeName = ((IEformInputField)con).Field; if (nodeName.Equals(dataElement)) { // 3. if (!holder.Controls.Contains(eFormUserControl) && (!loadedControlNames.Contains(controlNode.Attributes["controlName"].Value))) { holder.Controls.Add(eFormUserControl); loadedControlNames.Add(controlNode.Attributes["controlName"].Value); } base.SetInvalidStyle(con, "e7d1c8"); } } } } else if (con.HasControls()) { IterateOverChildControls(eFormUserControl, con, dataElement, nodeType, loadedControlNames, controlNode); } } }
/// <summary> /// Returns the name of the section in the EForm that contains the node. /// </summary> /// <param name="nodeName">name of parent or child node</param> /// <returns>name of the eform section</returns> private string GetEFormSectionFromNodeName(string nodeName) { XmlDocument eformsXml = this.GetEFormsXml(); XmlNodeList eformSections = eformsXml.SelectNodes("eform/eformSection"); foreach (XmlNode sectionNode in eformSections) { foreach (XmlNode controlNode in sectionNode) { // need to iterate over all files included in this eform System.Web.UI.UserControl eFormControl = base.GetEFormControl(controlNode.Attributes["controlName"].Value + ".ascx"); foreach (Control con in eFormControl.Controls) { if (con is IEformInputField) { // compares either field name or table name to return the given section of the eform if (((IEformInputField)con).Field != null && ((IEformInputField)con).Table != null) { if (((IEformInputField)con).Field.Equals(nodeName) || ((IEformInputField)con).Table.Equals(nodeName)) { // return section name that contains this field return(sectionNode.Attributes["name"].Value); } } } } } } return(null); }
protected void Page_Load(object sender, EventArgs e) { iconIBN.Href = Page.ResolveUrl("~/portal.ico"); RegisterScripts(); Response.Cache.SetNoStore(); if (controlName != "") { frmMain.Enctype = this.enctype; System.Web.UI.UserControl control = (System.Web.UI.UserControl)LoadControl(controlName); foreach (DictionaryEntry de in controlProperties) { control.GetType().BaseType.GetProperty(de.Key.ToString()).SetValue(control, de.Value, null); } try { phMain.Controls.Add(control); } catch (HttpException) { } } }
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); }
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")); }
private UserControl LoadUC(string LoadUCName, params object[] constructorParameters) { System.Web.UI.UserControl userControl = null; string ucControlPath = string.Empty; ucControlPath = LoadUCName; List <Type> constParamTypes = new List <Type>(); foreach (object constParam in constructorParameters) { constParamTypes.Add(constParam.GetType()); } if (!string.IsNullOrEmpty(ucControlPath)) { userControl = (UserControl)this.Page.LoadControl(ucControlPath); } ConstructorInfo constructor = userControl.GetType().BaseType.GetConstructor(constParamTypes.ToArray()); //And then call the relevant constructor if (constructor == null) { throw new MemberAccessException("The requested constructor was not found on : " + userControl.GetType().BaseType.ToString()); } else { constructor.Invoke(userControl, constructorParameters); } return(userControl); }
public override string[] getControlParameterKeys(System.Web.UI.UserControl control) { Dictionary <string, string> parameters = tokenizeCommandParameters(control.ID); List <string> keys = new List <string>(parameters.Keys); return(keys.ToArray()); }
/// <summary> /// 设置网面包屑 /// </summary> /// <param name="value">格式为[一级:/path/,二级:/path/filename.html|三级]</param> public void CrumbRegister(string value) { StringBuilder NodeList = new StringBuilder(); string[] Crumb = value.Split('|'); if (Crumb.Length > 1) { string[] Nodes = Crumb[0].Split(','); string[] _Node = new string[1]; NodeList.Append("<span>»</span>"); foreach (string Node in Nodes) { _Node = Node.Split(':'); NodeList.Append("<a href=\"" + _Node[1] + "\" title=\"" + _Node[0] + "\">" + _Node[0] + "</a><span>»</span>"); } NodeList.Append("<em>" + Crumb[1] + "</em>"); value = NodeList.ToString(); } else { value = "<span>»</span>" + value; } System.Web.UI.UserControl CrumbContainer = this.Master.Master.FindControl("ContainerPlaceHolder").FindControl("CrumbContainer") as System.Web.UI.UserControl; Literal ltCrumbContainer = CrumbContainer.FindControl("ltCrumbContainer") as Literal; ltCrumbContainer.Text = value; }
protected override void OnInit(EventArgs e) { base.OnInit(e); Control oControl = new System.Web.UI.UserControl().LoadControl(_usercontrolPath); if (HasSettings(oControl.GetType())) { DataEditorSettingsStorage ss = new DataEditorSettingsStorage(); List <Setting <string, string> > s = ss.GetSettings(((umbraco.cms.businesslogic.datatype.DefaultData)_data).DataTypeDefinitionId); ss.Dispose(); foreach (Setting <string, string> setting in s) { try { if (!string.IsNullOrEmpty(setting.Key)) { oControl.GetType().InvokeMember(setting.Key, System.Reflection.BindingFlags.SetProperty, null, oControl, new object[] { setting.Value }); } } catch (MissingMethodException) { } } } this.Controls.Add(oControl); if (!Page.IsPostBack) { ((IUsercontrolDataEditor)Controls[0] as IUsercontrolDataEditor).value = _data.Value; } }
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); } }
public static bool AlertRedirectWindowForAscx(System.Web.UI.UserControl ascxPage, string strMessage, string RedirectPage) { string strScript = @"alert( '" + strMessage + "' ); window.location.href='" + RedirectPage + "';"; System.Web.UI.ScriptManager.RegisterClientScriptBlock(ascxPage, ascxPage.GetType(), "Key1", strScript, true); return(false); }
/// <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); }
/// <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; }
private void Page_Load(object sender, System.EventArgs e) { Response.Expires = -1; this.lblDocumentCount.Text = string.Format("{0} documenti da firmare", this.GetSelectedDocuments().Count); DocsPaWR.Ruolo ruoloCorrente = UserManager.getRuolo(); DocsPaWR.Funzione funzioneFirma256 = ruoloCorrente.funzioni.FirstOrDefault(itm => itm.codice == "DO_DOC_FIRMA_256"); System.Web.UI.UserControl ctrl = null; if (funzioneFirma256 != null) { // Attivazione usercontrol smartclient ctrl = (System.Web.UI.UserControl) this.LoadControl("~/SmartClient/DigitalSignWrapper.ascx"); } else { // Attivazione usercontrol activex ctrl = (System.Web.UI.UserControl) this.LoadControl("~/ActivexWrappers/CapicomWrapper.ascx"); } this.Form.Controls.Add(ctrl); if (!this.IsPostBack) { ScriptManager.RegisterStartupScript(this, this.GetType(), "init", "Initialize();", true); this.addJSOnConfermaButton("return ApplySign()"); this.lblDocumentCount.Text = string.Format("{0} documenti da firmare", this.GetSelectedDocuments().Count); } }
protected void Page_Load(object sender, System.EventArgs e) { iconIBN.Href = Page.ResolveUrl("~/portal.ico"); RegisterScripts(); tableContactUs.Visible = GlobalResourceManager.Options["TableContactUsVisible"]; tableFeedback.Visible = GlobalResourceManager.Options["TableFeedbackVisible"]; lblProductName.Text = IbnConst.ProductFamily; // Default Settings printScript.Visible = false; frmMain.Visible = true; body.Attributes.Add("onload", "javascript:ScrollIt()"); //body.Attributes.Add("onscroll", "javascript:setcoords()"); frmMain.Enctype = this.enctype; if (controlName != "") { System.Web.UI.UserControl control = (System.Web.UI.UserControl)LoadControl(controlName); if (ControlProperty != null && ControlPropertyValue != null) { control.GetType().BaseType.GetProperty(ControlProperty).SetValue(control, ControlPropertyValue, null); } phMain.Controls.Add(control); if (control is IPageTemplateTitle) { this.Title = ((IPageTemplateTitle)control).Modify(this.Title); } } BindData(); }
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 } }
protected void Load1(Object sender, System.EventArgs e) { if (!_NoProgressOnPostBack || !Page.IsPostBack) { System.Web.UI.UserControl tmp = sender as System.Web.UI.UserControl; tmp.Page.Response.Write(loadHTML3); } }
private void CreateControlPanelScores() { PanelScores.Controls.Clear(); if (Scores.Count > 0) { foreach (Score score in Scores) { System.Web.UI.UserControl control = (System.Web.UI.UserControl)Page.LoadControl("~/UserControl/ScoreControl.ascx"); control.ID = "Score" + score.ScoreID.ToString(); HiddenField hiddenField = ( HiddenField )control.FindControl("HiddenFieldScoreID"); hiddenField.Value = score.ScoreID.ToString(); Table table = ( Table )control.FindControl("TableScore"); table.ID = "TableScore" + score.ScoreID.ToString(); table.CssClass = "TableScoreStyle"; TextBox textBoxScoreMin = ( TextBox )table.FindControl("TextBoxScoreMin"); textBoxScoreMin.Text = score.ScoreMin.ToString(); TextBox textBoxScoreMax = ( TextBox )table.FindControl("TextBoxScoreMax"); textBoxScoreMax.Text = score.ScoreMax.ToString(); TextBox textBoxScoreTexte = ( TextBox )table.FindControl("TextBoxScoreTexte"); textBoxScoreTexte.Text = score.ScoreTexte; ImageButton imageButtonSupprimer = ( ImageButton )control.FindControl("ImageButtonSupprimerScore"); imageButtonSupprimer.Click += new ImageClickEventHandler(ImageButtonScoreSupprimer_Click); ImageButton imageButtonSauver = ( ImageButton )control.FindControl("ImageButtonSauverScore"); imageButtonSauver.Click += new ImageClickEventHandler(ImageButtonScoreSauver_Click); PanelScores.Controls.Add(control); PanelScores.Controls.Add(new LiteralControl("<br/>")); } } // Scores a ajouter for (int i = Scores.Count + 1; i <= Scores.Count + NombreScores; i++) { System.Web.UI.UserControl control = (System.Web.UI.UserControl)Page.LoadControl("~/UserControl/ScoreControl.ascx"); // BUG29112009 //control.ID = "Score" + i.ToString(); control.ID = "ScoreToAdd" + i.ToString(); Table table = ( Table )control.FindControl("TableScore"); table.ID += i.ToString(); ImageButton imageButtonSupprimer = ( ImageButton )control.FindControl("ImageButtonSupprimerScore"); imageButtonSupprimer.Visible = false; ImageButton imageButtonSauver = ( ImageButton )control.FindControl("ImageButtonSauverScore"); imageButtonSauver.Visible = false; PanelScores.Controls.Add(control); PanelScores.Controls.Add(new LiteralControl("<br/>")); } }
public static bool hasControlParameterKey(CmsPage page, System.Web.UI.UserControl control, string keyName) { string[] keys = getControlParameterKeys(page, control); if (StringUtils.IndexOf(keys, keyName, StringComparison.CurrentCultureIgnoreCase) > -1) { return(true); } return(false); }
public static bool CreateMessageAlertForAscxPage(System.Web.UI.UserControl ascxPage, string strMessage) { { string strScript = "alert( \"" + strMessage + "\" )"; System.Web.UI.ScriptManager.RegisterClientScriptBlock(ascxPage, ascxPage.GetType(), "Key1", strScript, true); return(false); } return(true); }
private void BindControl() { string controlName = Request.QueryString["ctrl"]; if (controlName != "") { System.Web.UI.UserControl control = (System.Web.UI.UserControl)LoadControl(controlName); phItems.Controls.Add(control); } }
/// <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)); }
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="******"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); }
public override string getControlParameterKeyValue(System.Web.UI.UserControl control, string key, string defaultValue) { Dictionary <string, string> parameters = tokenizeCommandParameters(control.ID); if (parameters.ContainsKey(key)) { return(parameters[key]); } return(defaultValue); }
protected void Init1(Object sender, System.EventArgs e) { if (!_NoProgressOnPostBack || !Page.IsPostBack) { System.Web.UI.UserControl tmp = sender as System.Web.UI.UserControl; loadHTML2 = "<div id='loadingScreen' style='POSITION: absolute;Z-INDEX:5; LEFT: 5%; TOP: 5%;'><table border=0 height=100% width=100%><tr valign=middle> <td style='font-family: Verdana, Tahoma,arial,sans-serif;font-size: xx-small;font-weight:bold;'><center><img src='{0}'/> <b>" + text + "</b></td></tr></center></table></div>"; loadHTML2 = string.Format(loadHTML2, sourceImage); tmp.Page.Response.Clear(); tmp.Page.Response.Write(loadHTML1 + loadHTML2); tmp.Page.Response.Flush(); } }
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); } } }
public static string RenderControlToHTML(System.Web.UI.UserControl uc) { string rtv = string.Empty; _sb = new StringBuilder(); TextWriter _textWriter = new StringWriter(_sb); HtmlTextWriter _htmlTextWriter = new HtmlTextWriter(_textWriter); uc.RenderControl(_htmlTextWriter); rtv = _htmlTextWriter.ToString(); return(rtv); }
/// <summary> /// 输出用户控件的Html片段 /// </summary> /// <param name="control">控件的相对路径</param> /// <returns></returns> public static string RenderUserControl(string control) { Page page = new Page(); UserPublicCenter.WebControl.PageHead ctl1 = new UserPublicCenter.WebControl.PageHead(); System.Web.UI.UserControl ctl = (System.Web.UI.UserControl)page.LoadControl("~/" + control); page.Controls.Add(ctl); StringWriter writer = new StringWriter(); HttpContext.Current.Server.Execute(page, writer, false); return(writer.ToString()); }
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(); }
public static string RenderControl(this System.Web.UI.UserControl c) { StringBuilder sb = new StringBuilder(); using (System.IO.StringWriter sw = new StringWriter(sb)) { using (HtmlTextWriter w = new HtmlTextWriter(sw)) { c.RenderControl(w); } } return(sb.ToString()); }
/// <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; }
private void WriteField(string table, string[] fields) { // preserve sanity if (table == null || table == "" || fields.Length == 0) { return; } Hashtable stringMap = new Hashtable(); foreach (string s in fields) { stringMap[s] = ""; } string modFolder = Caisis.UI.Core.Classes.XmlUtil.GetParentModuleDirectory(_eformFileName + ".xml", "EForms"); XmlDocument eformsXml = XmlUtil.GetXmlDoc("~\\Modules\\" + modFolder + "\\EForms\\" + _eformFileName + ".xml"); XmlNodeList eformSections = eformsXml.SelectNodes("eform[@name='" + _eformName + "']/eformSection"); holder.Controls.Clear(); // need to record all the controls you have loaded so you don't load twice - jf List <string> loadedControlNames = new List <string>(); foreach (XmlNode sectionNode in eformSections) { foreach (XmlNode controlNode in sectionNode) { System.Web.UI.UserControl eFormControl = base.GetEFormControl(controlNode.Attributes["controlName"].Value + ".ascx"); foreach (Control con in eFormControl.Controls) { if (con is IEformInputField) { // we need to add (to our holder) the control containing table/fields and highlight the appropriate fields IEformInputField inputField = (IEformInputField)con; if (table == inputField.Table && stringMap.ContainsKey(inputField.Field)) { if (!holder.Controls.Contains(eFormControl) && (!loadedControlNames.Contains(controlNode.Attributes["controlName"].Value))) { holder.Controls.Add(eFormControl); loadedControlNames.Add(controlNode.Attributes["controlName"].Value); } base.SetInvalidStyle(con, "e7d1c8"); } } } } } }
protected void Page_Load(object sender, EventArgs e) { if (Session["AppLocation"] == null || Session.Count == 0 || Session["AppUserID"].ToString() == "") { IQCareMsgBox.Show("SessionExpired", this); Response.Redirect("~/frmlogin.aspx", true); } int PatientId = Convert.ToInt32(Request.QueryString["ptnpk"]); int VisitId = Convert.ToInt32(Request.QueryString["VisitId"]); IPediatric PrintManager; PrintManager = (IPediatric)ObjectFactory.CreateInstance("BusinessProcess.Pharmacy.BPediatric, BusinessProcess.Pharmacy"); DataSet theDSPrint = PrintManager.GetPharmacyDetailforLabelPrint(PatientId, VisitId); int i = 0; foreach (DataRow DR in theDSPrint.Tables[1].Rows) { System.Web.UI.UserControl uc = (System.Web.UI.UserControl)Page.LoadControl("usrctrlprintpharmacy.ascx"); uc.ID = "" + i + ""; Label lblFacility = ((Label)uc.FindControl("lblfacility")); lblFacility.Text = Convert.ToString(theDSPrint.Tables[0].Rows[0]["FacilityName"]); lblFacility.ID = "fac" + i + ""; Label lblpName = ((Label)uc.FindControl("lblpName")); lblpName.Text = Convert.ToString(theDSPrint.Tables[0].Rows[0]["Name"]); lblpName.ID = "pname" + i + ""; Label lbldrugName = ((Label)uc.FindControl("lbldrugName")); lbldrugName.Text = Convert.ToString(DR["DrugName"]); lbldrugName.ID = "dname" + i + ""; Label lblunit = ((Label)uc.FindControl("lblunit")); lblunit.Text = Convert.ToString(DR["unitName"]); lblunit.ID = "uname" + i + ""; TextBox txtprintInstruction = ((TextBox)uc.FindControl("txtprintInstruction")); txtprintInstruction.Text = Convert.ToString(DR["PatientInstructions"]); txtprintInstruction.ID = "PIns" + i + ""; Button theButton = new Button(); theButton.ID = "btn1" + i + ""; theButton.Text = "Print Label"; theButton.Click += new EventHandler(theButton_Click); Panel thepnl = new Panel(); thepnl.ID = "pnl" + i + ""; thepnl.BorderStyle = BorderStyle.Double; thepnl.BorderColor = System.Drawing.Color.Black; thepnl.Controls.Add(uc); thepnl.Controls.Add(theButton); thepnl.Controls.Add(new LiteralControl("<br /><br />")); pnlprintdialog.Controls.Add(thepnl); i++; } }
public static void LoadToolTipHelpValidationsForUserControl(ref System.Web.UI.UserControl oUserControl) { if (oUserControl != null) { UIFactory oUIFactory = new UIFactory(); UIWebUserControl oUIWebUserControl = oUIFactory.GetUIWebUserControl(oUserControl.AppRelativeVirtualPath.Substring(1)); foreach (UIControl oUIControl in oUIWebUserControl.ControlList) { //Find the Label Control to Add Tooltip and Help Control oLabelControl = null; oLabelControl = oUserControl.FindControl(oUIControl.LabelName); if (oLabelControl != null) { Label lbl = (Label)oLabelControl; //lbl.ToolTip = oUIControl.ToolTipText; //Check if already added the help if (lbl.Text.Contains("ShowHelpWindow") == false) { string strHelpPopup = ""; if (oUIControl.HTMLHelp != "") { strHelpPopup = " <a href=\"javascript:void(0);\" onclick=\"ShowHelpWindow('" + oUIControl.ControlId + "');\"><img src=\"/images/help_control.gif\" border=\"0\" align=\"absmiddle\"/></a>"; } lbl.Text = lbl.Text + strHelpPopup; //lbl.Text = oUIControl.LabelText+ strHelpPopup; } } //Find the Primary Control to add validations if (oUIControl.ControlName != "") { Control oPrimaryControl = oUserControl.FindControl(oUIControl.ControlName); if (oPrimaryControl != null) { ApplyToolTip(ref oPrimaryControl, oUIControl); if (ConfigurationManager.AppSettings["CONTROLS_ADD_VALIDATIONS_FROM_DB"].ToString() == "1") { ApplyValidations(ref oPrimaryControl, ref oUserControl, oUIControl); } } } } //Loop through UserControl controls to check for more User controls foreach (Control oControl in oUserControl.Controls) { Control oTmp = new Control(); oTmp = oControl; FindUserControlRecurrsive(ref oTmp); } } }
protected void Page_Load(object sender, EventArgs e) { if (Session.IsNewSession) { Response.Redirect("Home.aspx"); } userControl = (System.Web.UI.UserControl) this.LoadControl("UserControl/AdminMenu.ascx"); this.plcHldMenu.Controls.Add(userControl); if (!IsPostBack) { ///Uncomment below code after integrated with Admin Tool if (!((CustomPrincipal)Context.User).IsInRole(PubEntAdminManager.AdminRole)) { PubEntAdminManager.UnathorizedAccess(); } this.PageTitle = "Canned Search Setup"; } //Code for Hailstorm if (ucCancerTypeAdd != null) { ucCancerTypeAdd.SecurityCheck(); } if (ucSubjectAdd != null) { ucCancerTypeAdd.SecurityCheck(); } if (ucPubFormatAdd != null) { ucCancerTypeAdd.SecurityCheck(); } if (ucRaceAdd != null) { ucCancerTypeAdd.SecurityCheck(); } if (ucAudienceAdd != null) { ucCancerTypeAdd.SecurityCheck(); } if (ucLanguageAdd != null) { ucCancerTypeAdd.SecurityCheck(); } if (ucCollectionsAdd != null) { ucCancerTypeAdd.SecurityCheck(); } //End of code for Hailstorm }
public override bool getControlParameterKeyValue(System.Web.UI.UserControl control, string key, bool defaultValue) { Dictionary <string, string> parameters = tokenizeCommandParameters(control.ID); if (parameters.ContainsKey(key)) { try { return(Convert.ToBoolean(parameters[key])); } catch { } } return(defaultValue); }
protected void Page_Load(object sender, EventArgs e) { if (Session.IsNewSession) { Response.Redirect("~/Home.aspx"); } System.Web.UI.UserControl userControl = (System.Web.UI.UserControl) this.LoadControl("~/UserControl/AdminMenu.ascx"); this.plcHldMenu.Controls.Add(userControl); if (!IsPostBack) { btnDelete.Attributes.Add("onclick", "return confirm('Are you sure you want to delete this order?');"); btnDelete.Enabled = false; } }
protected void Page_Load(object sender, EventArgs e) { bodyTag.Attributes.Add("onload", "OnRedirect();"); Response.Cache.SetNoStore(); if (controlName != "") { frmMain.Enctype = this.enctype; System.Web.UI.UserControl control = (System.Web.UI.UserControl)LoadControl(controlName); phMain.Controls.Add(control); } RegisterScripts(); }
protected void Page_Load(object sender, EventArgs e) { iconIBN.Href = Page.ResolveUrl("~/portal.ico"); RegisterScripts(); Response.Cache.SetNoStore(); frmMain.Enctype = this.enctype; if (controlName != "") { System.Web.UI.UserControl control = (System.Web.UI.UserControl)LoadControl(controlName); phMain.Controls.Add(control); } }
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]); }
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); }
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); }
private void CreateControlPanelQuestions() { PanelQuestions.Controls.Clear(); for (int i = 1; i <= NombreQuestionEnchainee; i++) { System.Web.UI.UserControl control = (System.Web.UI.UserControl)Page.LoadControl("~/UserControl/QuestionControl.ascx"); control.ID = "Question" + i.ToString(); Table table = ( Table )control.FindControl("TableQuestionEnchainee"); table.ID += i.ToString(); Label label = ( Label )control.FindControl("LabelQuestionEnchainee"); label.Text += " <font color=\"#5282D4\">" + i.ToString() + "</font> : "; PanelQuestions.Controls.Add(control); PanelQuestions.Controls.Add(new LiteralControl("<br/>")); } }
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); }
protected void Page_Load(object sender, System.EventArgs e) { iconIBN.Href = Page.ResolveUrl("~/portal.ico"); RegisterScripts(); LocRM = new ResourceManager("Mediachase.UI.Web.App_GlobalResources.Modules.Resources.strTemplate", typeof(PageTemplateExternal).Assembly); tableContactUs.Visible = GlobalResourceManager.Options["TableContactUsVisible"]; lblProductName.Text = IbnConst.ProductFamily; if (Thread.CurrentThread.CurrentUICulture.DateTimeFormat.PMDesignator == String.Empty) { Is24Hours = "1"; } //Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), // "var Is24Hours = true;", true); int offset = User.GetCurrentBias(); TimeOffset = offset.ToString(); //Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), // "var TimeOffset = " + offset + ";", true); // Default Settings printScript.Visible = false; frmMain.Visible = true; body.Attributes.Add("onload", "javascript:ScrollIt()"); body.Attributes.Add("onscroll", "javascript:setcoords()"); frmMain.Enctype = this.enctype; if (controlName != "") { System.Web.UI.UserControl control = (System.Web.UI.UserControl)LoadControl(controlName); if (ControlProperty != null && ControlPropertyValue != null) { control.GetType().BaseType.GetProperty(ControlProperty).SetValue(control, ControlPropertyValue, null); } phMain.Controls.Add(control); if (control is IPageTemplateTitle) { this.Title = ((IPageTemplateTitle)control).Modify(this.Title); } } BindData(); }
public void LoadControl_WithControlThrowingHttpException_LoadsFallbackControl() { // arrange var containerControl = new Mock<IContainerControl>(); var fallbackControl = new UserControl { ID = "Foo.Bar" }; containerControl.Setup(tc => tc.LoadControl("~/Skins/OfMyChinnyChinChin/Controls/ViewPost.ascx")).Throws(new HttpException()); containerControl.Setup(tc => tc.LoadControl("~/Skins/_System/Controls/ViewPost.ascx")).Returns(fallbackControl); var skin = new SkinConfig { TemplateFolder = "OfMyChinnyChinChin" }; var skinControlLoader = new SkinControlLoader(containerControl.Object, skin); // act var control = skinControlLoader.LoadControl("ViewPost"); // assert Assert.AreSame(fallbackControl, control); }
public void AddControlToBody_WithPostComment_AddsControlToUpdatePanelAndUpdatePanelToCenterBodyControl() { // arrange var updatePanel = new UpdatePanel(); var postCommentControl = new PostComment(); var bodyControl = new UserControl(); var page = new SubtextMasterPage(); // act page.AddControlToBody("PostComment", postCommentControl, updatePanel, bodyControl); // assert Assert.AreEqual(postCommentControl, updatePanel.ContentTemplateContainer.Controls[0]); Assert.AreEqual(updatePanel, bodyControl.Controls[0]); Assert.IsTrue(postCommentControl.Visible); }
public void ChildControlsOfType() { var userControl = new UserControl {ID = "uc"}; var panel = new Panel {ID = "pl"}; var htmlUl = new HtmlGenericControl("ul") {ID = "ul"}; var htmlLi = new HtmlGenericControl("li") {ID = "li"}; htmlLi.Controls.Add(new CheckBox {ID = "ckb1"}); htmlUl.Controls.Add(htmlLi); panel.Controls.Add(htmlUl); panel.Controls.Add(new CheckBox {ID = "ckb2"}); userControl.Controls.Add(panel); var checkBoxes = userControl.Controls<CheckBox>(); Assert.AreEqual(2, checkBoxes.Count()); Console.Write("Found: "); checkBoxes.ToList().ForEach(ckb => Console.Write(ckb.ID + ", ")); }
protected override void OnInit(EventArgs e) { base.OnInit (e); Control oControl = new System.Web.UI.UserControl().LoadControl(_usercontrolPath); if (HasSettings(oControl.GetType())) { DataEditorSettingsStorage ss = new DataEditorSettingsStorage(); List<Setting<string, string>> s = ss.GetSettings(((umbraco.cms.businesslogic.datatype.DefaultData)_data).DataTypeDefinitionId); ss.Dispose(); foreach (Setting<string, string> setting in s) { try { if(!string.IsNullOrEmpty(setting.Key)) { oControl.GetType().InvokeMember(setting.Key, System.Reflection.BindingFlags.SetProperty, null, oControl, new object[] { setting.Value }); } } catch (MissingMethodException) { } } } // Add property data to the usercontrol if it supports it // TODO: Find the best way to test for an interface! IUsercontrolPropertyData propertyData = oControl as IUsercontrolPropertyData; if (propertyData != null) { propertyData.PropertyObject = new Property(((usercontrolData)_data).PropertyId); } this.Controls.Add(oControl); if (!Page.IsPostBack) ((IUsercontrolDataEditor)Controls[0] as IUsercontrolDataEditor).value = _data.Value; }
public SimpleForm(UserControl userControl) { this.userControl = userControl; this.form = FindForm(userControl); if (form == null) { throw new Exception("Form could not be found."); } if (form.ID == null) { throw new Exception("Form ID not set. The form ID is needed as this is the name of the table which the data will be stored."); } //grab the form controls LoadControls(); //create a schema formSchema = new FormSchema(form.ID); }
public void AddOpenTags(UserControl control, OpenGraphTags tags) { if (!string.IsNullOrEmpty(tags.Type)) _metaTagService.AddMetaTag(control, "og:type", tags.Type); if (!string.IsNullOrEmpty(tags.Url)) _metaTagService.AddMetaTag(control, "og:url", tags.Url); if (!string.IsNullOrEmpty(tags.Title)) _metaTagService.AddMetaTag(control, "og:title", tags.Title); if (!string.IsNullOrEmpty(tags.Description)) _metaTagService.AddMetaTag(control, "og:description", tags.Description); _metaTagService.AddMetaTag(control, "og:locale", "en_US"); _metaTagService.AddMetaTag(control, "og:site_name", "Providence Presbyterian Church"); if (tags.Type == "article") { _metaTagService.AddMetaTag(control, "article:publisher", FacebookSettings.ChurchPageUrl); _metaTagService.AddMetaTag(control, "article:author", FacebookSettings.ChurchPageUrl); if (!string.IsNullOrEmpty(tags.Section)) _metaTagService.AddMetaTag(control, "article:section", tags.Section); } }
/// <summary> /// load the spcify ascx file to page /// </summary> protected internal void LoadUserControl() { //when user spcify file if (!string.IsNullOrEmpty(this._userControl)) { try { base.CreateChildControls(); this.Controls.Clear(); this._control = (UserControl)Page.LoadControl(this._userControlPath + "/" + this._userControl); this.Controls.Add(this._control); } catch (System.Threading.ThreadAbortException tae) { //When exporting the excel, this exception will come up, and never mind it won't affect the system. } catch (Exception ex) { this.Page.Response.Write(ex.ToString()); throw ex; } } }
protected virtual void AfterUCAdd(UserControl item) { if (!this.Controls.Contains(item)) { this.Controls.Add(item); this.OnUserControlAdded(new UserControlAddedEventArgs(item)); if (item is IDynamicUserControl) { ((IDynamicUserControl)item).BeforeRender(); } foreach (var control in item.Controls) { var cmp = control as AbstractComponent; if (cmp != null) { cmp.ID = cmp.ID; this.OnComponentAdded(new ComponentAddedEventArgs(cmp)); } else if (control is LiteralControl || control is Literal) { continue; } else { throw new Exception(string.Format(ServiceMessages.NON_LAYOUT_CONTROL, control.GetType().ToString())); } } } }
private void PopupAggiungiRelazioneDealer_AggiungiButtonClicked(object sender, UserControl.RagioniSocialiCorrelate.AggiungiRelazioneDealerEventArgs e) { if (e.TipoRicerca == 1) { IDDealerScelto1HF.Value = e.IDDealer.ToString(); TBCodiceDealer1.Text = e.CodiceDealer; TBRagioneSociale1.Text = e.RagioneSociale; ddlTipoDealer1.Enabled = false; TBCodiceDealer1.Enabled = false; TBRagioneSociale1.Enabled = false; RBCodiceDealer1.Enabled = false; RBRagioneSociale1.Enabled = false; btnCD1.Enabled = false; btnRS1.Enabled = false; } else if (e.TipoRicerca == 2) { IDDealerScelto2HF.Value = e.IDDealer.ToString(); TBCodiceDealer2.Text = e.CodiceDealer; TBRagioneSociale2.Text = e.RagioneSociale; ddlTipoDealer2.Enabled = false; TBCodiceDealer2.Enabled = false; RBRagioneSociale2.Enabled = false; RBCodiceDealer2.Enabled = false; TBRagioneSociale2.Enabled = false; btnCD2.Enabled = false; btnRS2.Enabled = false; } PopupAggiungiRelazioneDealer.Hide(); creaRelUpdatePanel.Update(); }
private void InitByPath() { if (this.uc == null && this.Path.IsNotEmpty()) { if (this.Page != null) { var path = this.Path; if (!path.StartsWith("~") && !path.StartsWith("/") && HttpContext.Current != null && HttpContext.Current.CurrentHandler is System.Web.UI.Page) { var dir = System.IO.Path.GetDirectoryName(HttpContext.Current.Request.CurrentExecutionFilePath).Replace("\\", "/"); path = dir + "/" + path; } this.uc = (UserControl)this.Page.LoadControl(path); if (this.UserControlID.IsNotEmpty()) { this.uc.ID = this.UserControlID; } #if NET40 this.uc.ClientIDMode = this.UserControlClientIDMode; #endif this.AfterUCAdd(this.uc); } else { this.uc = UserControlRenderer.LoadControl(this.Path, this.UserControlID.IsNotEmpty() ? this.UserControlID : null); #if NET40 this.uc.ClientIDMode = this.UserControlClientIDMode; #endif } } }
public void ResolveValidationContainerToEnclosingParentRecursively() { // direct containment UserControl uc = new UserControl(); TestValidationControl vc = new TestValidationControl(); uc.Controls.Add(vc); Assert.AreSame(uc, vc.TheValidationContainer); // indirect containment uc = new UserControl(); vc = new TestValidationControl(); Control inBetweenControl = new Panel(); inBetweenControl.Controls.Add(vc); uc.Controls.Add(inBetweenControl); Assert.AreSame(uc, vc.TheValidationContainer); }
public UserControlAddedEventArgs(UserControl control) { this.userControl = control; }
/// <summary> /// /// </summary> public virtual void ClearCache() { this.uc = null; }
public void AddAttributes(UserControl control) { control.Attributes.Add("itemscope", null); control.Attributes.Add("itemtype", Itemtype); }
protected virtual void AfterUCRemove(UserControl item) { if (this.Controls.Contains(item)) { this.Controls.Remove(item); } }