asp.net-controls

How can I create a custom Repeater that displays Header, Footer based on properties?

不打扰是莪最后的温柔 提交于 2019-12-04 11:33:12
问题 I want to create a Repeater that displays the header/footer based on properties, only if the DataSource is empty. public class Repeater : System.Web.UI.WebControls.Repeater { public bool ShowHeaderOnEmpty { get; set; } public bool ShowFooterOnEmpty { get; set; } [DefaultValue((string)null), PersistenceMode(PersistenceMode.InnerProperty), TemplateContainer(typeof(System.Web.UI.WebControls.RepeaterItem)), Browsable(false)] public ITemplate EmptyTemplate { get; set; } } I also want to create a

ASP.NET: explicit vs implicit localization?

坚强是说给别人听的谎言 提交于 2019-12-04 06:17:33
To my mind the advantage of implicit localization over explicit localization is that if you have more than one property to localize for a given control, it's a more economical syntax. In the case where you just need to localize some text I use the asp:Localize control which only has a single property (Text) that renders to the UI. Is there a reason to use one over the other? Any style preference? Are there any speed differences? Implicit <asp:Localize ID="Localize1" runat="server" meta:resourcekey="Something" /> vs Explicit <asp:Localize ID="Localize1" runat="server" Text="<%$ Resources

ASP.NET control to render a <div>

空扰寡人 提交于 2019-12-03 22:05:15
The Label control in ASP.NET seems to render <span> tags, but is there a server control to render HTML within a <div> ? Sure, I could set display: block and it might look the same, but I'd rather not be nesting divs inside spans. Also I'd prefer not to use <%= MyVariable %> because that might not behave nicely on postbacks. Any suggestions, please? I think you need HtmlGenericControl class. It has a constructor which accepts a string variable which initializes a new instance of the HtmlGenericControl class with the specified tag: var div = new HtmlGenericControl("div"); It is also has

Is there a way to put inner controls inside a ASP.NET Custom Control?

↘锁芯ラ 提交于 2019-11-30 14:10:30
问题 I want to do something like (Updated example): <uc:Tabs> <Tab Name="A handy tab"> <Node Url="~/Default.aspx" /> <Node Url="~/Node2.aspx" /> </Tab> <Tab Name="Another handy tab"> <Node Url="~/Neato.aspx" /> <Node Url="~/Node3.aspx" /> <Node Url="~/Node4.aspx" /> </Tab> <uc:Tabs> Possible? Any tutorials or how-to's? I'm not sure what to even search on or what this is called so haven't found anything so far. Inner controls? Inner collection something something...? 回答1: Use the

ASP.NET Server Control Property Attribute must be required

橙三吉。 提交于 2019-11-29 11:25:49
I have a custom ASP.NET server control CustomControl with a property attribute Path . If the Path is not explicitly specified, then I want an exception to be thrown. For example, <myControls:CustomControl Path="somedirectory/someotherdirectory/somefile.ext" runat="server" /> should compile, and <myControls:CustomControl runat="server" /> should throw an exception. I realize I can do this in the getter of the Path property, but is there some attribute that necessitates this? Update Is there any mechanism for validating the values of the property attributes other than using in the getter methods

How do I disable all controls in ASP.NET page?

梦想与她 提交于 2019-11-28 19:24:05
I have multiple dropdownlist in a page and would like to disable all if user selects a checkbox which reads disable all. So far I have this code and it is not working. Any suggestions? foreach (Control c in this.Page.Controls) { if (c is DropDownList) ((DropDownList)(c)).Enabled = false; } John Sheehan Each control has child controls, so you'd need to use recursion to reach them all: protected void DisableControls(Control parent, bool State) { foreach(Control c in parent.Controls) { if (c is DropDownList) { ((DropDownList)(c)).Enabled = State; } DisableControls(c, State); } } Then call it like

ASP.NET Server Control Property Attribute must be required

别来无恙 提交于 2019-11-28 04:43:16
问题 I have a custom ASP.NET server control CustomControl with a property attribute Path . If the Path is not explicitly specified, then I want an exception to be thrown. For example, <myControls:CustomControl Path="somedirectory/someotherdirectory/somefile.ext" runat="server" /> should compile, and <myControls:CustomControl runat="server" /> should throw an exception. I realize I can do this in the getter of the Path property, but is there some attribute that necessitates this? Update Is there

How do I disable all controls in ASP.NET page?

别说谁变了你拦得住时间么 提交于 2019-11-27 12:17:30
问题 I have multiple dropdownlist in a page and would like to disable all if user selects a checkbox which reads disable all. So far I have this code and it is not working. Any suggestions? foreach (Control c in this.Page.Controls) { if (c is DropDownList) ((DropDownList)(c)).Enabled = false; } 回答1: Each control has child controls, so you'd need to use recursion to reach them all: protected void DisableControls(Control parent, bool State) { foreach(Control c in parent.Controls) { if (c is