asp.net control subclassing (textbox watermarks)
<p>Previously I have only really worked on applications, but now I am trying to learn web development.</p>

<p>For practice, I want to write an implementation of textbox watermarking - something similar to the TextBoxWatermark found in the asp.net ajax toolkit. I started by subclassing the existing textbox control, but I don't really know where to proceed after this. I see many examples of the web that look a bit like this:</p>

<pre><code>&lt;asp:Textbox id="tb" runat="server" value="Type in the code" onfocus="if (this.value == 'Type in the code') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Type in the code';}"&gt;&lt;/asp:Textbox&gt;
</code></pre>

<p>I guess I goal is to make a control that behaves something like this:</p>

<pre><code>&lt;asp:Textbox id="tbCode" runat="server" watermarkValue="Type in the code"&gt;&lt;/asp:Textbox&gt;
</code></pre>

<p>With the javascript stuff somehow buried in the class definition. I don't understand how to, for instance, register new attributes, or where to go throwing this javascript code. With my implementation, I want to be sure that when other bits of code query the textbox for its text contents, the watermark text is not returned, if that is all that is present. (something I was worried about in the first example.)</p>

<p>I don't really know where to look to start doing this. Could someone explain, or point me to a tutorial that has already covered this? </p>
