How do I manipulate the custom properties of a web control through javascript

  • 2020-03-30 00:01:05
  • OfStack

When programming, custom properties of web server controls are sometimes used. For example, there is no IsNotNull property in the TextBox control, but we can add an IsNotNull property ourselves to serve as a marker to facilitate our programming.

Although the IDE will prompt the warning that "IsNotNull is not a property of the TextBox", it does not prevent us from using it!

Code:
< Asp: TextBox ID = "TextBox1" runat = "server" IsNotNull = "e" > < / asp: TextBox>

Write Javascript code:


<script language=javascript type="text/javascript">
function getClick()
{
    var c=document.getElementById("<%=TextBox1.ClientID %>");
    if(c.IsNotNull == 1)
    {
        alert("IsNotNull is 1");
    }
    else if(c.IsNotNull == 0)
    {
        alert("IsNotNull is 0");
    }
    else
    {
        alert(c.IsNotNull); //A property value that IsNotNull when it is not 0 or 1
    }
}
</script>


Related articles: