This article is a mirror article of machine translation, please click here to jump to the original article.

View: 16628|Reply: 0

[ASP.NET] Response.Write outputs the specified html to the page body

[Copy link]
Posted on 4/3/2015 9:12:06 PM | | |

keywords:Response.Write , body 输出内容

===========================================

When writing asp.net web application, we need to output the corresponding client code directly on the page (e.g., output <span id='clientid' stype=''></span>). If we use Response.Write to output, we will find that the output content is on the first line of the page's source code, not in the body tag.

There are two solutions for this situation:

1. Define a variable xxx, use <%=xxx%> placed in the body tag;
2. Dynamically create a Literal Control (the Text attribute is the content we want to output, and the Mode is (if you need to use LiteralMode.Transform for the original output content), and add the Control to the corresponding Controls. See the MSDN documentation for more information about this control.
Method 1 is suitable for writing pages, not controls. Method 2 makes up for this problem




Previous:The GridView header font under ASP.NET is not bolded
Next:Teach you how to view Baidu Tieba hidden dynamic users' speech records
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com