Some options on the ASP.NET page prompt for specific implementations

  • 2020-06-12 08:47:01
  • OfStack

The following is divided into two cases. The ext control and asp control are analyzed respectively
1. If it is an asp control, the prompt needs to get the id of the current control, and the corresponding option can be obtained by querying the source code
id.
2. If it is an ext control, prompt for an option and directly get the id of the control in aspx design.
It is prompted by the js function below.

<script language="javascript">
        function YANDNCheck() {               
            if (document.getElementById("txtName") != null) {
                if (document.getElementById("txtName").value == "") {
                    alert(' The name cannot be empty! ');
                    document.getElementById("txtName").focus();
                    return false;
                }
            }           
            return true;
        }
    </script>


Type 1: Judgment information for the asp control
 
<script language="javascript">
        function YANDNCheck() {               
            if (document.getElementById(" Current correspondence in the source code textbox the id") != null) {
                if (document.getElementById(" Current correspondence in the source code textbox the id").value == "") {
                    alert(' The name cannot be empty! ');
                    document.getElementById(" Current correspondence in the source code textbox the id").focus();
                    return false;
                }
            }           
            return true;
        }
    </script>

Foreground display of the asp control

<table>
<tr>
<td> Name: </td>
<td><asp:TextBox id="txtName" />
<td><asp:Button onClientClick="return YANDNCheck();"/>
</tr>
</table>

Type 2: ext control judgment information

<script language="javascript">
        function YANDNCheck() {               
            if (document.getElementById("txtName") != null) {
                if (document.getElementById("txtName").value == "") {
                    alert(' The name cannot be empty! ');
                    document.getElementById("txtName").focus();
                    return false;
                }
            }           
            return true;
        }
    </script>


ext control foreground display information: directly call the corresponding control id

<table>
<tr>
<td> Name: </td>
<td><ext:TextBox id="txtName" />
<td><ext:Button onClientClick="return YANDNCheck();"/>
</tr>
</table>

Related articles: