custom-server-controls

How to pass method name to custom server control in asp.net?

I am working on a Customer Server Control that extends another control. There is no problem with attaching to other controls on the form. in vb.net: Parent.FindControl(TargetControlName) I would like to pass a method to the control in the ASPX markup. for example: <c:MyCustomerControl runat=server InitializeStuffCallback="Initializ...

UserControl rendering: write link to current page?

I'm implementing a custom control and in this control I need to write a bunch of links to the current page, each one with a different query parameter. I need to keep existing query string intact, and add (or modify the value of ) an extra query item (eg. "page"): "Default.aspx?page=1" "Default.aspx?page=2" "Default.aspx?someother=true&...

ASP.NET Custom Controls and "Dynamic" Event Model

OK, I am not sure if the title it completely accurate, open to suggestions! I am in the process of creating an ASP.NET custom control, this is something that is still relatively new to me, so please bear with me. I am thinking about the event model. Since we are not using Web Controls there are no events being fired from buttons, rathe...

ASP.NET Custom Control Styling

Hi There. I am in the process of beginning work on several ASP.NET custom controls. I was wondering if I could get some input on your guys/girls thoughts on how you apply styling to your controls. I would rather push it so CSS, so for the few controls I have done in the past, I have simply stuck a string property which allows you so ty...

ASP.NET Custom Controls - Alternatives to PostBack?

On my journey into the depths of custom ASP.NET control development I am obviously getting my head around the ASP.NET PostBack model and how it affects control development. I understand that controls have no "lifetime" in ASP.NET, and therefore must be re-initialized on each and every page load. We overcome this by persisting the object...

Dynamically add CalendarExtender to Textbox subclass server control?

I'm trying to create a server control, which inherits from TextBox, that will automatically have a CalendarExtender attached to it. Is it possible to do this, or does my new control need to inherit from CompositeControl instead? I've tried the former, but I'm not clear during which part of the control lifecycle I should create the new in...

ASP Nested Tags in a Custom User Control

I'm just getting started with Custom User Controls in c# and I'm wondering if there is any examples out there of how to write one which accepts nested tags. For example, when you create an "asp:repeater" you can add a nested tag for "itemtemplate". Any help appeciated! Cheers ...

How do you build an ASP.NET custom control with a collection property ?

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" /> ...

Child Control Initialization in Custom Composite in ASP.NET

Part of the series of controls I am working on obviously involves me lumping some of them together in to composites. I am rapidly starting to learn that this takes consideration (this is all new to me!) :) I basically have a StyledWindow control, which is essentially a glorified Panel with ability to do other bits (like add borders etc)...

Is there a way to Categorize my custom controls in the toolbox?

I have built a number of asp.net servercontrols into a class library, & I would like them to be grouped a certain way when the other members of my team reference my dll. Is that possible? How? ...

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

Can anyone recommend a dropdownlist control for asp.net (3.5) that can render option groups? Thanks ...

ASP.NET Custom Controls - Rendering Image from a Pool of Images at Design Time

I have been working on a ImageRotator control and finished weeding out any oddities with it tonight, and it works great. However, there is one thing that is bugging me with it. It doesn't display anything at design time (I just get the image placeholder). I have been Googling, and came across a good article from Rick Strahl (as always),...

Asp.Net 2 Custom Server Controls Properties

I am having a very hard time finding a standard pattern / best practice that deals with rendering child controls inside a composite based on a property value. Here is a basic scenario. I have a Composite Control that has two child controls, a textbox and a dropdown. Lets say there is a property that toggles which child to render. so: ...

How do I enable ViewState for child custom controls when disabled in parent?

I am trying to create a custom control that a "gridview" like control but specifcally for business objects that implement certain custom interfaces. In doing this I have come across the following problem. I have a control that I have disabled viewstate on (and I don't want to re-enable it) and it has a child control that I want viewst...

Removing CSS Class Attribute From Tag in a Custom Server Control

Greetings! I've created a custom button class to render the following: <span class="btnOrange"> <input type="submit" id="ctl00_MainContent_m_GoBack" value="Back" name="ctl00$MainContent$m_GoBack"/> </span> However, it renders like this instead (note the extraneous "class" attribute in the INPUT tag): <span class="btnOrange"> ...

Design Time Attribute For CSS Class in ASP.net Custom Server Control

Hopefully some Custom Control Designers/Builders can help I'm attempting to build my first custom control that is essential a client detail collection form. There are to be a series of elements to this form that require various styles applied to them. Ideally I'd like the VS 2005/2008 properties interface to be able to apply the CSSClas...

Whats the best way to programatically add a .swf to an asp.net page?

Is there a good way to add a .swf programatically to a panel on an asp.net page - ie: I know i could just insert the html tags: ie: <object type="application/x-shockwave-flash" data="yourflash.swf" width="" height=""> <param name="movie" value="yourflash.swf"> </object> But is there an existing .net or free FLASH component already t...

What is the proper way to maintain state in a custom server control?

This works, but is it the proper way to do it??? I have a custom server control that has an [input] box on it. I want it to kinda mimic the ASP.NET TextBox, but not completely. When the textbox is rendered i have a javascript that allows users to select values that are then placed in that input box. I have a public text property on t...

ASP.NET custom control rendering before <%= %> code executes to populate property

I have a custom control that exposes a property. When I set it using a fixed value, everything works correctly. But if I try to set its value using the <%= %> tags, it goes a little whacky: <cc:CustomControl ID="CustomControl" runat="server" Property1='<%= MyProperty %>' /> <%= MyProperty %> When this gets rendered, the <%= MyProper...

jQuery - Ajax

Hi. In A.ascx I have one DropDownList and one DIV. The DropDownList is populated dynamically. How do I load B.ascx into the DIV, when the user changes the selected index in the DropDownList. This should be done on the client side without postback, by using jQuery and Ajax. Thanks ...