protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (Page.Request.QueryString[QUERY_PAGE] != null) { int page = TypeConverter.ToInt32(Page.Request.QueryString[QUERY_PAGE]); PageIndex = page > 0 ? page - 1 : 0; } if (PagerSettings.PageButtonCount == 0) { PagerSettings.PageButtonCount = DEFAULT_PAGEBUTTONCOUNT; } PagerTemplate = new CompiledTemplateBuilder(new BuildTemplateMethod(Fake)); DataBind(); }
/// <summary> /// Adds icons to the configuration area of a block instance. Can be overridden to /// add additionsl icons /// </summary> /// <param name="canConfig"></param> /// <param name="canEdit"></param> /// <returns></returns> public virtual List<Control> GetConfigurationControls( bool canConfig, bool canEdit ) { List<Control> configControls = new List<Control>(); if ( canConfig || canEdit) { // Attributes CompiledTemplateBuilder upContent = new CompiledTemplateBuilder( delegate( Control content ) { Button trigger = new Button(); trigger.ClientIDMode = System.Web.UI.ClientIDMode.Static; trigger.ID = string.Format( "blck-cnfg-trggr-{0}", BlockInstance.Id.ToString() ); trigger.Click += trigger_Click; content.Controls.Add( trigger ); HiddenField triggerData = new HiddenField(); triggerData.ClientIDMode = System.Web.UI.ClientIDMode.Static; triggerData.ID = string.Format( "blck-cnfg-trggr-data-{0}", BlockInstance.Id.ToString() ); content.Controls.Add( triggerData ); } ); UpdatePanel upTrigger = new UpdatePanel(); upTrigger.ContentTemplate = upContent; configControls.Add( upTrigger ); upTrigger.Attributes.Add( "style", "display:none" ); // Icon to display block properties HtmlGenericControl aAttributes = new HtmlGenericControl( "a" ); aAttributes.Attributes.Add( "class", "properties icon-button show-modal-iframe" ); aAttributes.Attributes.Add( "height", "500px" ); aAttributes.Attributes.Add( "href", ResolveUrl( string.Format( "~/BlockProperties/{0}?t=Block Properties", BlockInstance.Id ) ) ); //aAttributes.Attributes.Add( "instance-id", BlockInstance.Id.ToString() ); configControls.Add( aAttributes ); } if ( canConfig ) { // Security HtmlGenericControl aSecureBlock = new HtmlGenericControl( "a" ); aSecureBlock.Attributes.Add( "class", "security icon-button show-modal-iframe" ); aSecureBlock.Attributes.Add( "height", "500px" ); aSecureBlock.Attributes.Add( "href", ResolveUrl( string.Format( "~/Secure/{0}/{1}?t=Block Security", Security.Authorization.EncodeEntityTypeName( BlockInstance.GetType() ), BlockInstance.Id ) ) ); configControls.Add( aSecureBlock ); // Move HtmlGenericControl aMoveBlock = new HtmlGenericControl( "a" ); aMoveBlock.Attributes.Add( "class", "block-move icon-button blockinstance-move" ); aMoveBlock.Attributes.Add("href", BlockInstance.Id.ToString()); aMoveBlock.Attributes.Add( "zone", BlockInstance.Zone ); aMoveBlock.Attributes.Add( "zoneloc", BlockInstance.BlockInstanceLocation.ToString() ); aMoveBlock.Attributes.Add( "title", "Move" ); configControls.Add( aMoveBlock ); // Delete HtmlGenericControl aDeleteBlock = new HtmlGenericControl( "a" ); aDeleteBlock.Attributes.Add( "class", "delete icon-button blockinstance-delete" ); aDeleteBlock.Attributes.Add("href", BlockInstance.Id.ToString()); aDeleteBlock.Attributes.Add( "title", "Delete" ); configControls.Add( aDeleteBlock ); } return configControls; }
public void Deny_Unrestricted () { CompiledTemplateBuilder ctb = new CompiledTemplateBuilder (new BuildTemplateMethod (BuildTemplate)); ctb.InstantiateIn (control); }
// Adds the necessary script elements for managing the page/zone/blocks /// <summary> /// Adds the config elements. /// </summary> private void AddTriggerPanel() { CompiledTemplateBuilder upContent = new CompiledTemplateBuilder( delegate( Control content ) { Button trigger = new Button(); trigger.ClientIDMode = System.Web.UI.ClientIDMode.Static; trigger.ID = "rock-config-trigger"; trigger.Click += trigger_Click; content.Controls.Add( trigger ); HiddenField triggerData = new HiddenField(); triggerData.ClientIDMode = System.Web.UI.ClientIDMode.Static; triggerData.ID = "rock-config-trigger-data"; content.Controls.Add( triggerData ); } ); UpdatePanel upTrigger = new UpdatePanel(); upTrigger.ContentTemplate = upContent; this.Form.Controls.Add( upTrigger ); upTrigger.Attributes.Add( "style", "display:none" ); }
// ********************************************************************* // ApplyTemplates // /// <summary> /// Applies templates to control the ui generated by the control. If no /// template is specified a custom template is used. If a template is found /// in the skins directory, that template is loaded and used. If a user defined /// template is found, that template takes priority. /// </summary> /// // ********************************************************************/ private void ApplyTemplates() { string pathToHeaderTemplate; string pathToFooterTemplate; string pathToItemTemplate; string pathToAlternatingItemTemplate; string keyForHeaderTemplate; string keyForItemTemplate; string keyForAlternatingItemTemplate; string keyForFooterTemplate; // Are we using skinned template? if (Page != null) { // Set the file paths to where the templates should be found keyForHeaderTemplate = Globals.Skin + "/Templates/UserList-Header.ascx"; keyForItemTemplate = Globals.Skin + "/Templates/UserList-Item.ascx"; keyForAlternatingItemTemplate = Globals.Skin + "/Templates/UserList-AlternatingItem.ascx"; keyForFooterTemplate = Globals.Skin + "/Templates/UserList-Footer.ascx"; // Set the file paths to where the templates should be found pathToHeaderTemplate = Globals.ApplicationVRoot + Globals.ForumsDirectory + "/Skins/" + keyForHeaderTemplate; pathToItemTemplate = Globals.ApplicationVRoot + Globals.ForumsDirectory + "/Skins/" + keyForItemTemplate; pathToAlternatingItemTemplate = Globals.ApplicationVRoot + Globals.ForumsDirectory + "/Skins/" + keyForAlternatingItemTemplate; pathToFooterTemplate = Globals.ApplicationVRoot + Globals.ForumsDirectory + "/Skins/" + keyForFooterTemplate; // Attempt to get the skinned header template if (HeaderTemplate == null) HeaderTemplate = Globals.LoadSkinnedTemplate(pathToHeaderTemplate, keyForHeaderTemplate, Page); // Attempt to get the skinned item template if (ItemTemplate == null) ItemTemplate = Globals.LoadSkinnedTemplate(pathToItemTemplate, keyForItemTemplate, Page); // Attempt to get the skinned alternating item template if (AlternatingItemTemplate == null) AlternatingItemTemplate = Globals.LoadSkinnedTemplate(pathToAlternatingItemTemplate, keyForAlternatingItemTemplate, Page); // Attempt to get the footer template if (FooterTemplate == null) FooterTemplate = Globals.LoadSkinnedTemplate(pathToFooterTemplate, keyForFooterTemplate, Page); } // If the item template is null we force our view if (ItemTemplate == null) { ExtractTemplateRows = true; HeaderTemplate = new CompiledTemplateBuilder(new BuildTemplateMethod(BuildHeaderTemplate)); ItemTemplate = new CompiledTemplateBuilder(new BuildTemplateMethod(BuildItemTemplate)); FooterTemplate = new CompiledTemplateBuilder(new BuildTemplateMethod(BuildFooterTemplate)); } }