ASP.NET C#正确地为页面生成HTML [英] ASP.NET C# Properly Generating HTML for Page

查看:47
本文介绍了ASP.NET C#正确地为页面生成HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我意识到这可能是我应该知道的基本知识,但是我是在自学C#和asp.net,所以在这一点上我有些失落.

我现在有2页.一个是.aspx(包括aspx.cs文件),该文件为空白,并且从cs文件中的Page_Load函数为其生成html.HTML非常简单,它只是图像和一些文本.

第二个文件是一个shtml文件,其中包含许多内容,服务器端包括可编辑和不可编辑区域.我想将我的Web应用程序放入该文件.我的asp.net应用程序使用Response.Write只是写出html.此页面无法很好地进行,因为所有操作都将其写在页面顶部,这是因为它首先运行并在顶部生成.

如何使其能够在页面内(例如特定DIV内)生成HTML代码的位置,以免干扰页面.学习如何做的起点在哪里.

我应该注意,我不需要用户进行任何交互.所有这些都应该立即产生.

解决方案

所以,如果我正确理解了这些问题.您已经有一个现有的页面/应用程序(shtml文件),您希望通过将ASP.NET页面的输出包含在现有页面中来使用某些新的ASP.NET组件进行扩展?

这不是ASP.NET支持"的开箱即用的东西,您不会"使用SSI执行aspx页面.但是您可以做相反的事情,ASP.NET页确实支持 SSI .因此,如果您未在shtml文件中使用任何其他脚本,那么这可能是一个解决方案.

否则,唯一常见的解决方案是使用AJAX框架并从现有页面中调用ASP.NET或使用iframe解决方案.在这两种情况下,都可以使用客户端来调用ASP.NET页并合并结果.

然后您在控制ASP.NET页的输出时遇到问题吗?

多态播客"在在ASP.NET WebForms中控制HTML 上有一篇不错的文章..>

I realize this is probably a fundamental thing I should know but I am self-teaching myself C# and asp.net so I am a little lost at this point.

I right now have 2 pages. One is an .aspx (with aspx.cs file included) that is blank and html is generated for it from a Page_Load function in the cs file. The HTML is very simple and it is just an image and some text.

The second file is a shtml file which has lots of things, serverside includes, editable and noneditable areas. I want to put my webapp into this file. My asp.net app uses Response.Write to just write out the html. This does not flow well with this page as all that does is write it at the top of the page which is because it is ran first and generates it at the top.

How can I make it to where I can generate HTML code inside the page, like within a specific DIV so it does not mess up the page. Where would a starting point be in learning how to do that.

I should note that I do not need any interaction from the user. All of this should generate right away.

解决方案

So if i have understood the questions correctly. You already have an existing page/application (the shtml file) that you want to extend with some new ASP.NET components by including output from the ASP.NET page in the existing page?

This is as not something that is out of the box "supported" by ASP.NET and you "won't" be able to execute the aspx page using SSI. But you can do the opposite, an ASP.NET page does support SSI. So if you are not using any other scripts in the shtml file this might be a solution.

Otherwise the only common solutions would be either to use an AJAX framework and let it call the ASP.NET from within the existing pages or to use an iframe solution. In both cases the client will be resposible for making the calls to the ASP.NET pages and merging the results.

And then you have a issue with controlling the output from the ASP.NET page?

The Polymorphic Podcast has a good article on Controlling HTML in ASP.NET WebForms .

这篇关于ASP.NET C#正确地为页面生成HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆