How to build ASP. NET server control via JavaScript

Source: Internet
Author: User

Summary

Although ASP. NET server control has been criticized by everyone, but the user control (ACSX) in some scenarios is still very useful.

In the case of some polar beads, we use JavaScript to dynamically build the controls on the page, but suppose we encounter a server-side control, a user control that I want to build with JavaScript, what do I do?

We often say that server-side controls run on the server, so what does that mean?

The service-side control, which is essentially a wrapper for building HTML statements, generates a set of HTML and returns it to the client via the HTTP protocol in a pre-arranged manner. As a result, the server-side controls we wrote were already absent in response to HTTP requests. --This is called running on the server

That being the case, then the client naturally does not have the possibility of parsing a server-side control.

Based on the above, we can tell that it makes no sense to output a server-side control directly to the body via JavaScript.

Then we change a way of thinking, that is, the service side of the construction of the control must be through the Web server, then we can pass an HTTP request, and without destroying the current page of the case, the server-side control after the conversion of the HTML source code it?

With this idea, the solution is simple--iframe

We can set up an ASPX page, which is primarily a server-side control, and then, through the loading of the IFRAME, displays the server-side control on the current page.

?

Of course, it's just an effect, and it doesn't really make sense to build a server-side control with JavaScript. Instead, an IFRAME is built that contains only the server-side controls.

If you make a move, you can add all the components in the IFRAME to the main page and remove the IFRAME through some JavaScript code, so that it becomes a whole page, but it may be the result of some control ID conflicts.

Article for the author original, reproduced please indicate the source http://www.zizhusoft.com/note/show.aspx?id=f562b47a-ddd0-4771-a93d-78e9fdbd7b72, thank you for your cooperation

How to build ASP. NET server control via JavaScript

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.