ILearnable .Net

April 27, 2009

Tiny drips of Asp.Net juice

Filed under: Uncategorized — andreakn @ 05:03

long time no see,
I’ve been a busy little bee working on a fairly large web site for online gambling (horse races), with some SERIOUSLY cool software/frameworks. Going from the outside in it’s been jQuery, EPiServer 5, Asp.Net 3.5, WCF, SOA, NHibernate. And I have learned more from this project than any other. I’m going to publish reference code (for my own later googling pleasure) from this project for quite a while I reckon. I’m starting easy with some webcontrols we have used throughout the solution. using our own has made it possible to enable/utilize jQuery very easily.

to ensure the ID of controls are fixed, we have used this little trick:

public class ClientIdHiddenField: HiddenField{
   public override string ClientID{ get{ return ID; } }

This enables us to be certain that the jQuery selectors all work as expected

similarly we have overridden labels/buttons/etc to enable us to give the webcontrols a TextKey property (e.g. TextKey=”/app/game/gamewindow/buygame” ) declaratively, the TextKey is then used to lookup the correct text from the Translate function in EPiServer

public class TranslateButton: Button
public string TextKey{ get; set; }

protected override void OnPreRender(EventArgs e)
    if (!string.IsNullOrEmpty(TextKey) && string.IsNullOrEmpty(Text))
       Text = LanguageUtil.TranslateOrBlank(TextKey);

As these are all just Custom Controls (no code-front file) we can specify their namespace in web.config:

<pages validateRequest="false" enableEventValidation="false">
      <add tagPrefix="cc" namespace="OurNamespace.CommonUC" assembly="OurAssemblies.Web" />

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at

%d bloggers like this: