Tagged with controls
postbacks add a lot of weight to your page and you don't always need them. Find out when you can do without them and how to use ASP.NET without paying the postback price.
Published in ASP.NET on Sunday, February 8th, 2009
One of the biggest waste I see in using viewstate is that it persists values that are already set in the aspx. These get set every time that the page runs and don’t need to be round tripped to the browser so that they will be persisted. I did a little experiment a while back [...]
Published in ASP.NET, Server controls on Sunday, February 1st, 2009
Use custom attributes to take the tedious work out of creating server control properties that persist to ViewState. Declare a normal property and use an Attribute to tag it for storage to ViewState. See how to use reflection to see which properties need to be persisted.
Published in Server controls on Wednesday, August 13th, 2008
Here’s a small plug for Joel who has just released a book on something quite dear to my heart, ASP.NET server controls. It’s called Advanced ASP.NET AJAX Server Controls for .NET Framework 3.5 and looks very interesting. I’m looking forward to adding it to my library. It’ll be nice to have an update to Nikhil’s [...]
Published in Server controls on Thursday, July 10th, 2008
ASP.NET smartie pants Scott Guthrie has linked to a really interesting article about supporting templated areas in ASP.NET controls. This is aimed at people doing user controls, but the same thing will work if you want to have a templated area in your own custom control. I’ve created a little sample that shows how to [...]
Published in Server controls on Saturday, June 10th, 2006
I don’t know if this will be useful to anyone else but I thought this was kind of a neat trick for messing around with ASP.NET page rendering for debugging purposes. My problem was I wanted to stop the rendering of a page at a certain point so I could see how the scripts were [...]
Published in ASP.NET, Javascript, Server controls on Friday, April 7th, 2006
ASP.NET 2.0 has a really nice feature that lets you compile site or component resources like javascript files into your assembly file instead of deploying these shared files to the wwwroot/aspnet_client directory like in ASP.NET 1.x. This makes your component/website much easier to deploy because it means you can keep everything you need in one [...]
Published in ASP.NET, Server controls on Wednesday, January 11th, 2006
Step 1: Create a WebControl that implements the IPostBackEventHandler interface. In my example I’ve created a CustomButton control that is a HTML <span> element that acts like a real button by trigging a postback and firing a Click event. public class CustomButton : WebControl, IPostBackEventHandler { public CustomButton() { } public void RaisePostBackEvent(string eventArgument) { [...]
Published in Server controls on Monday, October 24th, 2005
To get a resource from the current assembly: Stream stream = this.GetType().Assembly().GetManifestResourceStream("namespace.file"); To get all the names of all the resources in your current assembly: string[] resources = this.GetType().Assembly.GetManifestResourceNames(); foreach(string resourceName in resources) { Debug.WriteLine(resourceName); }
Published in .NET on Tuesday, March 1st, 2005
Came across an interesting problem yesterday trying to handle the SelectedIndexChanged event for a DropDownList that was inside a Repeater. I found a wonderful article on Databinding that gave me most the information I needed, but their method of handling events just didn’t work for me. My first problem was that I originally did the [...]
Published in ASP.NET, Javascript on Tuesday, January 25th, 2005
First you need to declare an event in the class that’s going to raise the event. This is just like declaring a normal variable: public event EventHandler MyEvent; Then you need a method that’s going to be called to raise the event. This goes into the same class that you just declared the event in. [...]
Published in .NET on Wednesday, November 3rd, 2004
It’s simple, but annoying to find in the documentation.. <asp:textbox id="MultilineTextBox" rows="10" columns="80" <strong>textmode="MultiLine"</strong> runat="server"/> Wish textboxes were multi-line automatically if they had more than one row..
Published in ASP.NET on Wednesday, September 29th, 2004