Share html elements to call server instances

零下一度
Release: 2017-06-24 09:49:41
Original
1662 people have browsed it

Background: Secondary development using asp.net three-tier server control

When I was developing today, I found that many things in this system are encapsulated, and I also found a problem

Dopostback How to use this method

Because I found that some html elements neither have interactive methods bound to them nor are they server controls

But you can interact with data after clicking on them

After careful study, I decided to share it with everyone

First add a server control

Binding method to server control

When the page is clicked, as shown below

Then I added an html element and bound it to the dopostback method in js

Then As shown in the figure below, this html element can execute the method used by the first server control

View the page source and find out The page automatically generates this thing

Combined with the parameters of dopostback

aaa is actually eventTarget "" is the following eventArgument

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

Because after the form1 form is submitted, this only executes the first sentence in the bbb_onclick() method

__DoPostBack('aaa', ''); If there is a follow-up after your bbb method, the page can continue to execute

So when you use it, it is best to add this return false. After all, this method is written by humans. It is best to add

Another method is to simulate the server click

It can be achieved like this

The above is the detailed content of Share html elements to call server instances. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template