custom-server-controls

Render Self-Closing Tag in ASP.NET custom control derived from Control

I'm working on a Facebook FBML controls library and would like to create my FBML controls somewhat patterned like the ASP.NET WebControls library. I have a base class that handles rendering by default; here's my render method: protected override void Render(HtmlTextWriter writer) { AddAttributesToRender(wri...

How to create an ASP.NET custom control with a dash in the name?

I want to set up an ASP.NET custom control such that it has a custom name, specifically, with a hyphen within it, so it might look like this in markup: <rp:do-something runat="server" id="doSomething1" /> I don't mind if this syntax requires setting up a tag mapping in web.config or something to that effect, but the tagMapping element ...

Reach Session in a UserControl loaded in a WebPart

I have a WebPart in MOSS 2007 that sets a variable in Session. Later, when loading a Webpart that loads a UserControl, the Session is NULL (not just the variable) The Webpart that loads the UserControl have access to Session properly. The Webpart "lives" within a ClassLibrary DLL, the UserControl are part of a WebApplication. It seems...

ASP.NET Treeview control supporting drag & drop?

Can anybody recommend a treeview component for ASP.NET that supports drag & drop (between it's own nodes - it's for a content management system to rearrage the pages). Don't mind if it's open source or commercial (can't quite stretch to the treeview from Telerik though). Shame.. Any other options? Thanks. ...

ASP.NET inject javascript in user control nested in update panel

Hi folks, I'm trying to load javascript code with a user web control into a page via a the Page.LoadControl method during an asyncron post back of an update panel. I've tried the specially for that scenario designed methods of the scriptmanager, but the javascript just doens't get returned to the user. To explain my scenario a bit bet...

Custom TextBox with built-in Validator: server side validation not firing

I have a class that looks like this: public class TextField : TextBox { public bool Required { get; set; } RequiredFieldValidator _validator; protected override void CreateChildControls() { base.CreateChildControls(); _validator = new RequiredFieldValidator(); _validator.ControlToValidate = this.ID; ...

ASP.NET Custom Controls

How do you create a custom control (not an ASCX control) and, more importantly, use it in your project? I'd prefer not to create a separate project for it or compile it as a DLL ...

Problem with embedding CrystalViewerControl inside a Custom Web Control

I'm building a Custom Web Control in ASP.NET 2.0 that embeds the CrystalViewerControl inside it. The CrystalViewerControl accepts its ReportSource as a ServerFileReport, that means that my report file I'm trying to view is accessed as a Web service. I successfully render and create the CrystalReportViewer control and the ServerFileRepor...

ASP.NET Custom Server Control (GridView), DataBinding, and Control Lifecycle conflict.

Hi, I have created a Custom Server Control (Inherited from GridView). On the page, the GridView is DataBound to a DataSet, so I do not know at design time what columns will be present in my GridView. Now, what I want to do is, to add a textbox in every Cell for the GridView Header row, and those textboxes will control column filtering...

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

Update: This turned into a blog post, with updated links and code, over at my blog: http://egilhansen.com/2008/11/30/how-to-take-control-of-style-sheets-in-aspnet-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...

Inheriting from an WebControl that implements IScriptControl

I am attempting to create a subclass of a web conmtrol that implements IScriptControl. I have managed to make the serverside chanegs that I need, and the control has happily inherited all of the clientside bahaviour from its base class. I now wish to add to this behaviour. Specifically I need my class to handle a javascript event that ...

ASP.NET Creating a Rich Repeater, DataBind wiping out custom added controls...

So...I had this clever idea that I'd create my own Repeater control that implements paging and sorting by inheriting from Repeater and extending it's capabilities. I found some information and bits and pieces on how to go about this and everything seemed ok... I created a WebControlLibrary to house my custom controls. Along with the e...

Displaying available strongly typed resource classes in Property Window

I'm extending the Gridview Web Control as my first attempt at creating a custom control. As part of the extension I am encapsulating the localization of the grid column headers within the control. Among others, I'm exposing a couple of properties to enable this feature: bool AutoLocalizeColumnHeaders - enables the feature string Heade...

How to persist List<T> property in ASP.NET Custom Control?

I have the following property in a custom control: List<myClass> _items; public List<myClass> Items{ get { return _items; } set { _items= value; } } In my codebehind, I add items to the collection as in... myCustomControl.items.Add(new myClass()); However, these are not persisted across postbacks. What is the proper way to...

How to stop Visual Studio css intellisense breaking when css is added via a custom control

Hi all, I have created a simple Asp.Net custom control which automatically combines all the correct stylesheets to send to the client (based on browser type/version/etc). However, because at design-time the head tag looks something like this... <head> <cc:CssControl runat="server" /> </head> ...VS is unable to provide intellisen...

ASP.NET Web Application Testing Experiences

Hi Everyone, In our project, we have 20 simple web controls, 8 composite web controls including Ajaxable Custom Grid. And all modules are developed dependent to these controls. And now I afraid to change a control, because it effects modules more then I think. It's too late I know but I need to write some test cases for my controls. ...

Dealing with ASP.Net Custom Controls in MVC

Hi, I have looked around on the Internet trying to answer this question. It seems to be kind of complicated though! Seems to come up with all sorts of different topics such as the HtmlHelper and other stuff. Basically. How can you use custom controls with MVC? In a way that avoids doing anything that is frowned upon. Also, Is it true t...

Update ControlState from client script?

Hi I have an IScriptControl that needs to persist data from the user across postbacks. Currently I'm writing the data to a hidden field, but I'd like to switch to ControlState. So my question is: Is it possible to update ControlState data from client script? Thanks, Aleko ...

asp.net custom control rendering outside of form tag

I am having an issue with a custom control rendering its contents (child controls) outside of the tag which leads to runtime errors and issues. In an attempt to simplify things as much as I can, I created the control below but it has the very same issue. I have tried inheriting from Control, WebControl and CompositeControl all resulting...

Design-time trouble with ASP.NET v2.0 Custom Control, with List<T> for child items

Folks, I am having a devil of a time with a custom control. The control is very simple - it just displays a list of "StepItems" (rendered as table rows), each with an icon. When I first drag it onto a page, and add StepItems to its collection, it renders perfectly. If I provide some text for its Header property, that also renders per...