Unable to gain access to cutom textbox property through javascript
I have made a custom textbox that inherits from textbox.


        using System.Drawing;
        using System;
        using System.Collections.Generic;
        using System.ComponentModel;
        using System.Linq;
        using System.Text;
        using System.Web;
        using System.Web.UI;
        using System.Web.UI.WebControls;

        namespace GNB.DPS.MVAD.CustomWebControls
        {
            [Designer("GNB.DPS.MVAD.CustomWebControls.MVADTextBox, GNB.DPS.MVAD.CustomWebControls"), DefaultProperty("Text"), ToolboxData("<{0}:MVADTextBox runat=server></{0}:MVADTextBox>")]
            public class MVADTextBox : TextBox
            {
                public virtual string SampleText
                {
                    get
                    {
                        string s = (string)ViewState["SampleText"];
                        return s ?? String.Empty;
                    }
                    set
                    {
                        ViewState["SampleText"] = value;
                    }
                }

                [Bindable(false)]
                [Category("Properties")]
                [DefaultValue("")]
                [Localizable(true)]
                public string Mask
                {
                    get
                    {
                        String tblName = (String)ViewState["Mask"];
                        return (Mask ?? String.Empty);
                    }

                    set
                    {
                        ViewState["Mask"] = value;
                    }
                }

                protected override void OnLoad(EventArgs e)
                {
                    if(!Page.IsPostBack)
                    {
                        if(Text == String.Empty)
                        {
                            if (SampleText != "")
                            {
                                CssClass = "sampleText";
                                this.Text = SampleText;
                                var onFocus = "<script language=\"javascript\">function ClearField(input) { if(input.value == input.defaultValue){input.value = \"\"; input.className = 'regularText';} } </script>";
                                var onBlur = "<script language=\"javascript\"> function PopulateField(input) {if (input.value == \"\") {input.value = input.defaultValue; input.className = 'sampleText'; } } </script>";

                                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OnFocus", onFocus);
                                this.Attributes.Add("onfocus", "ClearField(this);");

                                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OnBlur", onBlur);
                                this.Attributes.Add("onblur", "PopulateField(this);");
                            }
                        }
                    }
                }
            }
        }

On the .aspx it can be used as such...

    <script language="javascript">
        function MaskInput(input) {
            var textbox = document.getElementById(input.id);
            var mask = textbox.getAttribute('Mask');

        } 
    </script>

        <MVAD:MVADTextBox ID="tbMVAD2" runat="server" SampleText="Hello" Mask="###-###" onKeyPress="MaskInput(this);" />

However... this line returns null var mask = textbox.getAttribute('Mask');

in the view source we see...

    <input name="ctl00$cphListBody$tbMVAD2" type="text" value="Hello" id="ctl00_cphListBody_tbMVAD2" class="sampleText" onKeyPress="MaskInput(this);" onfocus="ClearField(this);" onblur="PopulateField(this);" />

notice how there is no property in the source called Mask or Sample Text. Therefore I can't access the property through javascript. Is my control set up properly? Any Ideas?
Unable to gain access to cutom textbox property through javascript
===

I have made a custom textbox that inherits from textbox.


        using System.Drawing;
        using System;
        using System.Collections.Generic;
        using System.ComponentModel;
        using System.Linq;
        using System.Text;
        using System.Web;
        using System.Web.UI;
        using System.Web.UI.WebControls;

        namespace GNB.DPS.MVAD.CustomWebControls
        {
            [Designer("GNB.DPS.MVAD.CustomWebControls.MVADTextBox, GNB.DPS.MVAD.CustomWebControls"), DefaultProperty("Text"), ToolboxData("<{0}:MVADTextBox runat=server></{0}:MVADTextBox>")]
            public class MVADTextBox : TextBox
            {
                public virtual string SampleText
                {
                    get
                    {
                        string s = (string)ViewState["SampleText"];
                        return s ?? String.Empty;
                    }
                    set
                    {
                        ViewState["SampleText"] = value;
                    }
                }

                [Bindable(false)]
                [Category("Properties")]
                [DefaultValue("")]
                [Localizable(true)]
                public string Mask
                {
                    get
                    {
                        String tblName = (String)ViewState["Mask"];
                        return (Mask ?? String.Empty);
                    }

                    set
                    {
                        ViewState["Mask"] = value;
                    }
                }

                protected override void OnLoad(EventArgs e)
                {
                    if(!Page.IsPostBack)
                    {
                        if(Text == String.Empty)
                        {
                            if (SampleText != "")
                            {
                                CssClass = "sampleText";
                                this.Text = SampleText;
                                var onFocus = "<script language=\"javascript\">function ClearField(input) { if(input.value == input.defaultValue){input.value = \"\"; input.className = 'regularText';} } </script>";
                                var onBlur = "<script language=\"javascript\"> function PopulateField(input) {if (input.value == \"\") {input.value = input.defaultValue; input.className = 'sampleText'; } } </script>";

                                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OnFocus", onFocus);
                                this.Attributes.Add("onfocus", "ClearField(this);");

                                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OnBlur", onBlur);
                                this.Attributes.Add("onblur", "PopulateField(this);");
                            }
                        }
                    }
                }
            }
        }

On the .aspx it can be used as such...

    <script language="javascript">
        function MaskInput(input) {
            var textbox = document.getElementById(input.id);
            var mask = textbox.getAttribute('Mask');

        } 
    </script>

        <MVAD:MVADTextBox ID="tbMVAD2" runat="server" SampleText="Hello" Mask="###-###" onKeyPress="MaskInput(this);" />

However... this line returns null var mask = textbox.getAttribute('Mask');

in the view source we see...

    <input name="ctl00$cphListBody$tbMVAD2" type="text" value="Hello" id="ctl00_cphListBody_tbMVAD2" class="sampleText" onKeyPress="MaskInput(this);" onfocus="ClearField(this);" onblur="PopulateField(this);" />

notice how there is no property in the source called Mask or Sample Text. Therefore I can't access the property through javascript. Is my control set up properly? Any Ideas?