custom-server-controls

ASP.NET / C#: DropDownList SelectedIndexChanged in server control not firing

空扰寡人 提交于 2019-11-30 13:22:45
问题 I'm creating a server control that basically binds two dropdown lists, one for country and one for state, and updates the state dropdown on the country's selectedindexchanged event. However, it's not posting back. Any ideas why? Bonus points for wrapping them in an UpdatePanel (having rendering issues; maybe because I don't have a Page to reference?) Here's what I have (with some extra data access stuff stripped out): public class StateProv : WebControl { public string SelectedCountry; public

How to take control of style sheets in ASP.NET Themes with the StylePlaceHolder and Style control

纵然是瞬间 提交于 2019-11-30 00:45:55
Update: This turned into a blog post, with updated links and code, over at my blog: https://egilhansen.com/2008/12/01/how-to-take-control-of-style-sheets-in-asp-net-themes-with-the-styleplaceholder-and-style-control/ The problem is pretty simple. When using ASP.NET Themes you do not have much say in how your style sheets are rendered to the page. The render engine adds all the style sheets you have in your themes folder in alphabetic order, using the <link href=”...” notation. We all know the order of the style sheets are important, luckily asp.nets shortcomings can be circumvented by

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 you build an ASP.NET custom control with a collection property?

五迷三道 提交于 2019-11-29 01:45:49
I'm looking to do something akin to <cstm:MyControl runat="server"> <myItem attr="something" /> <myItem attr="something" /> </cstm:MyControl> What's the bare bones code needed to pull this off? Rick's example shows something akin to <cstm:MyControl runat="server"> <myItems> <cstm:myItem attr="something" /> <cstm:myItem attr="something" /> </myItems> </cstm:MyControl> I'd prefer the more terse syntax if possible. Note: Feel free to suggest a better title or description. Even if you don't have edit rights, I'm glad to edit the entry for the sake of the community. Chris Pietschmann Here's a

calling a public function of an asp.net ajax server control from client side

旧城冷巷雨未停 提交于 2019-11-28 11:38:43
问题 I want to make a ajax server control in ASP.NET and in that application I have a textbox and I want to send text of that textbox to function that is created in ASP.NET ajax server control class and that function return some result based on text. My Application uses Server controls which are Imported from External DLL added as a reference. This Server Control will make use of AJAX to complete its functionality. To use My control, I would add the Script Manager and My Control on the .aspx page

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 you build an ASP.NET custom control with a collection property?

Deadly 提交于 2019-11-27 16:11:17
问题 I'm looking to do something akin to <cstm:MyControl runat="server"> <myItem attr="something" /> <myItem attr="something" /> </cstm:MyControl> What's the bare bones code needed to pull this off? Rick's example shows something akin to <cstm:MyControl runat="server"> <myItems> <cstm:myItem attr="something" /> <cstm:myItem attr="something" /> </myItems> </cstm:MyControl> I'd prefer the more terse syntax if possible. Note: Feel free to suggest a better title or description. Even if you don't have

Dropdownlist control with <optgroup>s for asp.net (webforms)?

北城余情 提交于 2019-11-26 15:08:10
Can anyone recommend a dropdownlist control for asp.net (3.5) that can render option groups? Thanks I've used the standard control in the past, and just added a simple ControlAdapter for it that would override the default behavior so it could render <optgroup>s in certain places. This works great even if you have controls that don't need the special behavior, because the additional feature doesn't get in the way. Note that this was for a specific purpose and written in .Net 2.0, so it may not suit you as well, but it should at least give you a starting point. Also, you have to hook it up using