HTML element Call Server method

Source: Internet
Author: User

Background: Two-time ASP. Three-tier server controls for development

Today, at the time of development, we found a lot of things in this system that were encapsulated and found a problem.

Dopostback how this method is used

Because I found out that some HTML elements have neither the method of binding interaction nor the server control

You click to interact with the data

Carefully studied the next decision to share the next

First add a server control

Binding methods to server controls

When you click on a page, such as

Then I added an HTML element in JS to give it a way to bind Dopostback.

You can then execute the method used by the first server control as shown in this HTML element

View page Source Discovery page automatically generated this thing

Combining the parameters of the Dopostback

AAA is actually eventtarget "" is the back of the eventargument

As for that return false is to prevent the page from continuing to execute

Because the Form1 form is only executed after the Bbb_onclick () the first sentence in this method

__doPostBack (' AAA ', '); If you have BBB, there's a follow-up to this method, and the page continues.

So when you're using it, it's best to add this return false, after all, this is the best way to write.

Another way to simulate a server click

Like this, it can be done.

HTML element Call Server method

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.