The html element calls the server method, and the html element calls

Source: Internet
Author: User

The html element calls the server method, and the html element calls

Background: asp.net layer-3 Server Control for Secondary Development

During Development today, we found that many things in this system are encapsulated and a problem is also found.

How to Use the Dopostback method?

I found that some html elements do not bind interaction methods to them, nor are they server controls.

You click to interact with data.

 

 

 

I have studied it carefully and decided to share it with you.

First, add a server control.

 

 

Binding Methods to server controls

 

 

As shown in figure

 

 

Then I added an html element to bind dopostback to it in js.

 

Then, as shown in this html element, You can execute the method used by the first Server Control.

 

 

View the page source. This is automatically generated on the page discovery page.

Combined with dopostback Parameters

 

Aaa is actually eventTarget "" and eventArgument.

The return false is used to prevent the page from being executed.

Because after the form1 form is submit, this is only the first sentence in the method of bbb_onclick ().

_ DoPostBack ('aaa', ''); if your bbb method is followed by a later method, the page can continue to be executed.

Therefore, when using this method, it is best to add this return false. After all, this method is the best method for human writing.

Another method is to simulate server clicks

It can be implemented like this

 

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.