One cause of JavaScript error caused by the onselectedindexchanged event of the dropdownlist control of ASP. NET

Source: Internet
Author: User

I am writing ASP. net, you need to use the dropdownlist onselectedindexchanged event to trigger changes to the webpage content. After the result is complete, start IE debugging. ie produces JavaScript errors. The wrong statement is ASP. net automatically generated, the error statement is

Theform. Submit ();

I was puzzled, because there is no compilation error, and there is no HTML error, in an empty ASP. net web page, only one dropdownlist control, the results are completely OK, the server side can accept the returned events.

From this point of view, there is a problem with the web page and the automatically generated JavaScript produces an error. What is the error?

After more than an hour of experimentation, I found that there was a button control on my webpage, whose ID allowed me to write it as submit, as shown below:

<Asp: button id = "Submit" runat = "server" text = "Submit"/>

It turns out that its ID conflicts with the form's submit method. The javascript interpreter of IE does not know the original submit method. After the button ID is changed to another name, the problem is solved. It seems that there are still some problems with IE's javascript interpreter. Can methods with the same name and objects be separated.

I hope that I will not make such low-level mistakes in the future.

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.