The SelectedIndexChanged event of the DropDownList control cannot be triggered.

Source: Internet
Author: User

Let's take a look at the questions of netizens:



According to the Asp. NET mechanism, the DropDownList write control in html markup is a little different from the Dynamically Loaded control. If you write the DropDownList control in html markup, that is, the. aspx webpage, the user code is correct. However, if the control is dynamically loaded in. aspx. cs, it cannot be loaded in the Page_Load event. If it is loaded as this, it will not work even if AutoPostBack = true.
The correct method isLoad in the Page_Init event.


In the following dynamic real-time operations, the first step is to run the code of netizens, and it is determined that the Code cannot be run. Then Insus. NET writes the Page_Load event and the Showpage method Comment out, and copies the dynamically generated DropDownList control to the page_Init event. The last miracle happened, and it was able to run correctly.



Code in the demo:

Page_Init (= ListItem (, + = Page_Load (ddl_SelectedIndexChanged (= + dl. SelectedValue + View Code


 

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.