How To Create A Custom Control

  1. Create a new ASP.NET Web Application, Windows Forms Control Library or Class Library project
  2. Create a new class and inherit from System.Web.UI.WebControls.WebControl or from a specific control (like TextBox)
  3. Override the Render method and call writer.write() to write raw HTML to the page. ASP.Net server tags won’t work
  4. Use WriteBeginTag(), WriteEndTag(), RenderBeginTag(), RenderEndTag(), AddAttribute(), AddStyleAttribute() and WriteAttribute() to create HTML tags and attributes
  5. Add design-time attributes to properties, like:
    [Category(“Appearance”)]
    [Description(“The text to be shown in the control”)]
  6. Define a tagprefix attribute:
    [assembly: System.Web.UI.TagPrefix(“Anthoro.WebControls”, “awc”)]
    namespace Anthoro.WebControls
    { …
  7. Add a toolbox icon:
    1. Create a 16×16 pixel bitmap (BMP 16 colors) with the same name as the control.
    2. Add it to the root of your project
    3. Set its Build Action to “Embedded Resource”
  8. Add additional resources (stylesheet, images, text files, …) and mark them as “Embedded Resource” also
  9. Add an Assembly attribute for each resource to your AssemblyInfo.cs:
    [assembly: WebResource(“Anthoro.Controls.style.css”, “text/css”, PerformSubstitution = true)]
    When the PerformSubstitution parameter is set to true, the resource will be processed and other webresource URL’s inside it will be parsed and replaced (works only for text-based resources:
    background-image: url(‘<%= WebResource("Anthoro.Controls.back.png")%>‘);
  10. Pay attention to the full namespace and folder structure where your resources are stored. The resource name is build as: Namespace + Subfolders + filename
  11. At design-time, the control is displayed by running the rendering logic. To override this, use the GetDesignTimeHtml(), GetEmptyDesignTimeHtml() and GetErrorDesignTimeHtml() methods

Update: Unlike in C#, in VB.Net the subfolders are not taken into account with the namespace. So the example above in point 10 will be: Namespace + filename

CSS: The Great Spicificity Swindle

Great understandable article about the 3 most important subjects in CSS: the cascade, inheritance and specificity!I recently held a workshop for my colleagues covering these as the primary subjects and more advanced CSS techniques. This article explains them in an understandable non-technical language.

read more | digg story

How To Minimize Your Javascript and CSS Files for Faster Page Loads

Over the last 11 years I’ve spent a great deal of time trying to improve client websites with an eye for minimalist interface design and code. While the minimalist design esthetic is not the choice for every client the notion of less code and faster load times always goes over well. Today, many of web applications I design and code for have a plethora of Javascript and CSS files. Fortunately, there are many options to solve this rather simple problem. Compression, obfuscation and bundling are all great options.

Below you’ll find a list of the sites I’ve visited to learn more about Javascript and CSS compression. Please let me know through email or a comment if you know of any other great compression resources, and I’ll be glad to post them. Most of the descriptions below are taken from the developers of the example. Thanks, Max.

Max Kiesler – How To Minimize Your Javascript and CSS Files for Faster Page Loads

Powered by ScribeFire.

Google Code Revamps with jQuery

This is a very nice example of how the open technologies of jQuery and Google API’s can be combined to create very powerful websites.

We have revamped Google Code, the site which is the home to developers, and open source hosting. A ton of work went into cleaning up the UI integrating and unifying content, and simplifying.
The site uses jQuery for a lot of its work, and also eats a lot of dogfood.

Ajaxian – Google Code Revamps with jQuery

Powered by ScribeFire.

C# MYSQLWrapper Class and PHPWrapper-Script

The MYSQLWrapper Class is a small and simple to use solution for accessing serverside MySQL Databases at a standard webspace that supports php and mysql.
I thought it would be useful because many of you have got those cheep php/mysql supported sites and want to use data at client side.
SQL queries and non query commands proceed as follows:

  1. The client side c# programm passes the needed sql command to the serversided script using http request.
  2. The serversided script performs sql statement an returns the result, if there is any, back to the client
  3. Now the client parses returned data and creates a Resultset that behaves simliar to the sqlDataReader

The Code Project – C# MYSQLWrapper Class and PHPWrapper-Script

Powered by ScribeFire.

A List Apart: Articles: Graceful E-Mail Obfuscation

Many web users don’t understand the inevitable consequences of exposing their e-mail address on the web. Experienced web developers and website owners, however do. Thousands of spam bots tirelessly crawl the web to collect e-mail addresses exposed on websites, in blog comments and elsewhere. These addresses end up in databases sold to unsavory marketers, who bombard the owners’s inboxes with unsolicited mail.
Of course, spam is an increasingly complicated problem that can never be solved by the efforts of web developers alone. But don’t underestimate your own powers.

A List Apart: Graceful E-Mail Obfuscation

Aptana Studio

We are very proud to have released Aptana Studio 1.0 (formerly Aptana IDE). After over two years of non-stop development and close to a million downloads, we have finally reached ‘1.0’. Along with the release of 1.0, we have also created two editions of the product: Community and Professional. The Community Edition is the keystone of the Studio product, where all core features and capabilities are developed. The Professional Edition brings additional features and services beyond the free Community edition. Aptana Studio isn’t the only product we’re working on, and you’ll see more from us soon. In the mean time, if you are using Aptana Studio professionally, support our efforts by ‘going Pro’. Whichever edition you chose to use, Community or Professional, we look forward to your feedback, feature requests, and comments. It is our community that helps us build a better product — a product that ultimately is for you.

-Paul Colton, CEO
Aptana Studio

250+ Tools and Resources For Coding the Web

We’re all living on the web, and we all seem to be starting our own websites, so it’s time we all learned the languages that make it run. We’ve gathered over 250 resources to help you get going. This list is aggregated from previous Mashable posts.

Mashable.com: 250+ Tools and Resources For Coding the Web

Particletree » Ranked Searches with SQL

A handy trick to add some sort of ranking to SQL search results:

Creating some sort of search functionality is something we all have to do at one point or another. For the good cases, we have fulltext search or an external program available to us. But sometimes, getting down and dirty with plain SQL is the only option.

SELECT
SUM(((LENGTH(Body) - LENGTH(REPLACE(Body, 'term', '')))/4))
AS Occurrences

Particletree: Ranked Searches with SQL

Net Profiles

With Net Profiles, mobile computing becomes a whole lot easier. It eliminates the need to manually reconfigure your network settings when you move your desktop/laptop computer to another location. Once a profile is created, Net Profiles can configure your IP settings, proxy settings, mapped drives, default printer, wallpaper, and screen resolution with a click of a button; as well as run any number of user-defined applications upon activation of a profile.

Net Profiles

Digital Web Magazine – jQuery Crash Course

As developers, we have more and more JavaScript libraries to choose from and, of course, the option not to use any at all. Over time, we each tend to favor one method of coding over another. For those who’d like to learn more about jQuery, one of the more popular libraries, here’s a crash course written with code-savvy web designers in mind.

Digital Web Magazine: jQuery Crash Course