custom-server-controls

HTML 'name' attribute generated for ASP.net child controls, instead of the unique 'ID' attribute

The generated HTML code for my custom ASP.net server control generates the name attribute for child controls, instead of the id attribute. Something like this : <span id="GridView2_ctl02_editdis"> <input type="text" name="GridView2$ctl02$editdis$ctl00"/> </span> The ID for the custom control itself is apparently proper. What is e...

Custom Web Control, ITemplate not recognised

Hi, Hopefully an easy one, I have created a Custom Repeater control that extends System.Web.UI.WebControls.Repeater. I Have added two ITemplate Properties to this control and add these when required and in the desired manner. Everything is working absolutely fine but I'm having a problem in Visual Studio having these new Templates reco...

Overriding Controls Collection on WebControl

Hello All, I am trying to override the Controls collection of a control that inheirts from WebControl so that when a user adds controls to the webcontrol I can put buttons before and after it and kind of put it in its own wrapper. Something like this: protected override ControlCollection Controls { EnsureChildControls(); retur...

Custom server control: specifying event declaratively on ASPX code

Hi, I'm currently working on several custom ASPX server controls. Of course these controls do also expose events. Now one possibility is to register a handler in the code, more specifically in the page where the custom server control resides...like protected void Page_Load(object sender, EventArgs e) { myCustomControl.Click += new ....

.Net Repeater equivalent for a single object?

Hi, Could someone try to recommend the best cause of action to solve the request below: I have created a number of extended classes using the Repeater class as a Base and love the flexibility, the ease and the results of doing this. What I want to to do now is to make a similar Custom Web Control for a single object (i.e the DataSource...

.net Page events firing order changing.

Ok this is a really annoying bug that I have been having issues with all morning!. I have a custom control that we have used on many project that has properties that are set and stored in Viewstate by the calling pages onload. the control sets up childcontrols with propertes on the CreateChildControls() method of the custom control. N...

Custom Server Controls - Base Classes & Usage

Hi I hope someone out there can shed some light on the topic of creating server controls, the control base classes and the usage of those classes. Here is an example of what I want to achieve. I want to create a custom panel control that one can instantiate in the ASPX markup like so: <acme:Panel ID="MyPanel" runtat="server" Scrollin...

Templated databound controls - template property

I have a templated databound control with several templates. I want to extend this with some new functionality. Ideally I want to do something like this: <MyControl runat="server"> <ClassTemplate ClassName="Article"> template definition comes here </TemplateClass> <ClassTemplate ClassName="News"> template defin...

Generic ServerControl syntax?

Is there a way that I can have a server control MyControl<T> so that I can register and use it in an aspx page like so <mc:MyControl<ThingForControlToUse> ID="instanceOfMyControl" runat="server" Obviously the designer doesn't like this, are there any cool ways round it other than creating a non generic wrapper with a type parameter...

Custom Server Control causes full postbacks inside of UpdatePanel

I have a custom server control that seems to work fine until I put it in an UpdatePanel. Once inside the UpdatePanel it continues to work fine but the UpdatePanel now does full postbacks when my custom server control does a postback. Do I need to do anything to make my custom server control do async postbacks while inside an UpdatePa...

Inheriting a web server control in a simple fashion?

Hi, I'm having a Repeater used as a sort of Paging TagCloud. To do so, I've added simple properties to the Page's ViewState such as a Page, RowCount, etc... I feel like it doesn't belong there but I had bad experiences with server controls, debugging, dll and deployment. Could I just inherit the Repeater class, add a few ControlState/V...

Add packaged javascript to page from ASP.NET server control?

Is it possible to create an ASP.NET server control that packages some javascript that will be emitted to the aspx page at design-time rather than run time? I am trying to create a control that will have "default" javascript. I can add jvascript using RegisterClientScriptBlock, but then a web developer can't modifiy the javascript - it is...

How Do I Change the render behavior of my custom control from being a span

When writing a custom control it always rendered as an HTML span element. How can I change it for example to a div? ...

Implement a HierarchicalDataBoundControl for ASP.NET

I want to implement a Hierarchical data bound control for ASP.NET. I used Implementing IHierarchy Support Into Your Custom Collection as a basis to create my hierarchical collection. I also created a HierarchicalDataSourceControl for the collection. Everything works: I can bind it to an ASP.NET TreeView and it renders the data correctly...

CompareValidator works in listview's editItemTemplate but not in insertitemtemplate

Hi, I have a validation problem I have a listview, in the edit item template I have two composite controls with a textbox inside I put a comparevalidator on it <asp:CompareValidator ID="myCompareValidator" runat="server" ControlToValidate="mycompositecontrol1" ControlToCompare="mycompositecontrol2" Operator="GreaterThanEqual" Type="D...

ASP.NET Server Control - Reuse Type/Objects in Web References

Hello, I was wondering if it's possible to reuse objects in web references in an ASP.NET Server control? (basically keeping the same web reference name) I have a few web services (.asmx) that I want to group with the same web reference name, however when I consume them using the same name they append a 1 at the end and with all object ...

Custom web server control fails when calling a web service

Hello all, I've created a web server control, it works fine. Problems start when I try calling an external web service. I am using a script manager and it's directed to the following location --> http:\localhost\UserNamesData.asmx. My server control creates some html controls as well some javascript code. When the user clicks a submit ...

ASP.NET StateBag and Custom Controls

Lets pretend that for some reason I want to create a custom control that is derived from Control and not WebControl. Let us also assume that I need to process attributes (i.e. implement IAttributeAccessor) and that I want to do so by using an AttributeCollection just like WebControl does. WebControl implements the Attributes property l...

What is "the book" for building ASP.NET Controls?

Back in the glory days of ASP.NET 1.1, I bought "Developing Microsoft ASP.NET Server Controls and Components" by Nikhil Kothari and Vandana Datye. I loved this book -- I read it and read it and developed all kinds of cool controls using it. I got my money's worth -- you should see the book, it's totally destroyed. It was probably the ...

ASP.NET Templated Control

Hello, I'm attempting to build a templated control. You'll see that as part of the Field section, I'd like to be able to define controls as children. When I attempt to compile I'm receiving the error message "MyTemplateControl.Field' does not have a public property named 'Button'". Does anyone know how to accomplish what I'm trying to...