I read some articles with regards on watermarks in windows app, but I found it to be quite complicated. What is the best way to implement watermark in textboxes?

Add this:

public static class TextBoxWatermarkExtensionMethod {
    private const uint ECM_FIRST = 0x1500;
    private const uint EM_SETCUEBANNER = ECM_FIRST + 1;

    [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
    private static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, uint wParam, [MarshalAs(UnmanagedType.LPWStr)] string lParam);

    public static void SetWatermark(this TextBox textBox, string watermarkText) {
        SendMessage(textBox.Handle, EM_SETCUEBANNER, 0, watermarkText);
    }
}

After that you can do this:

myTextbox.SetWatermark("This is the watermark");
Comments
thanks

Hello, i'm sorry if this is late but where could I call the watermark class for my textbox? Tried in my form's load event but it's not present.

That code works for winforms applications, not ASP.NET. To watermark on ASP you'll have to use javascript, if it's possible.

This question has already been answered. Start a new discussion instead.