ASP. NET page options for prompt judgment

Source: Internet
Author: User

There are two possible cases. Use the ext control and asp control for analysis.
1. If it is an asp control, you must obtain the id of the current control when prompted. You can obtain the corresponding options by querying the source code.
.
2. If it is an ext control, prompt a certain option to directly obtain the id of the control in the aspx design.
Use the following js functions to prompt.
<Script language = "javascript">
Function YANDNCheck (){
If (document. getElementById ("txtName ")! = Null ){
If (document. getElementById ("txtName"). value = ""){
Alert ('name cannot be blank! ');
Document. getElementById ("txtName"). focus ();
Return false;
}
}
Return true;
}
</Script>

First: asp control judgment Information

<Script language = "javascript">
Function YANDNCheck (){
If (document. getElementById ("the current textbox id in the source code ")! = Null ){
If (document. getElementById ("id of the textbox in the source code"). value = ""){
Alert ('name cannot be blank! ');
Document. getElementById ("the current textbox id in the source code"). focus ();
Return false;
}
}
Return true;
}
</Script>

Front-end display of asp control
<Table>
<Tr>
<Td> name: </td>
<Td> <asp: TextBox id = "txtName"/>
<Td> <asp: Button onClientClick = "return YANDNCheck ();"/>
</Tr>
</Table>
Second: ext control judgment Information
<Script language = "javascript">
Function YANDNCheck (){
If (document. getElementById ("txtName ")! = Null ){
If (document. getElementById ("txtName"). value = ""){
Alert ('name cannot be blank! ');
Document. getElementById ("txtName"). focus ();
Return false;
}
}
Return true;
}
</Script>


Ext control front-end display information: directly call the id of the corresponding control.
<Table>
<Tr>
<Td> name: </td>
<Td> <ext: TextBox id = "txtName"/>
<Td> <ext: Button onClientClick = "return YANDNCheck ();"/>
</Tr>
</Table>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.