Asp. NET gets the control ID on the master page or content page

Source: Internet
Author: User

Originally want to give a button to add a confirm, different scores hint different information (more than 80 qualified, less than 80 unqualified, prompted whether to submit), the first to use the button. Atribute.add (); But every time it gets to the value of the label control before the refresh, later on the Internet to see the use of viewstate[], but still no, no way, can only use JS:

<script>function myconfirm () {    if (document.getElementById (' lbl '). value>=80)    {return confirm (' Qualified, Do you want to submit? ')}    else    {return confirm (' unqualified, is it submitted? ')}}</script>

However, always error: undified; should be unable to find the ID of the control, no way, suddenly thought can be used in the browser F12, see the need to get the ID of the control, the original use of the master page after the resolution of the ID is the master page + control ID.

Finally put the code written today, later encountered can also see:

<asp:button id= "Btn_commit" runat= "Server" text= "Submit Results" class= "btn btn-primary pull-right" onclientclick= "return MyFunction () "onclick=" Btn_commit_click "/><script type=" Text/javascript ">functionmyFunction () {varHj=document.getelementbyid (' Ctl00_content_lbl_hj '). InnerText; if(hj>=80)                                    {                                          returnConfirm (' Your rating is ' eligible ' to confirm the submission? ')) ; }Else{                                      returnConfirm (' Your rating is ' unqualified ' to confirm the submission? '))   ; }                                }                                    </script>

Asp. NET gets the control ID on the master page or content page

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.