动态创建网页 [英] Creating Web page dynamically

查看:87
本文介绍了动态创建网页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个要求,例如动态创建完整的网页.
意味着用户应该有一个界面,他们可以设计所需的文本框,标签,下拉列表等表单,并且必须保存该表单,并且在刷新时,它应该在菜单中具有链接,并且通过单击它必须加载该表单并且用户应该能够在该页面中进行数据输入并将其保存到DB

i have a requirement like, creating the complete web page dynamically.
means user should have an interface, they can design the form like required text box,label,drop down etc. and that has to be saved and while refresh,it should have a link in menu and by clicking it the form has to be loaded and user should be able to do data entry in that page and save it to DB

推荐答案

从此处开始:
Start from here: How to create ASPX Page Dynamically - A Step Ahead Series?[^]

Try!


不要以为这是ASP.NET的第二大琐事,仅次于根本不使用服务器端代码的最琐事. ,只有HTML?所有服务器端Web技术都允许从头开始创建页面.这是几乎每个人都应该学习的最基本技能.

这可能是我能想到的最简单的食谱:

将网页添加到您的ASP.NET Web项目.假设这是从名为"Default.aspx"的项目模板创建的第一页.服务器端C#文件后面的代码将为"Default.aspx.cs".

除了以下内容,从"Default.aspx"中删除所有内容:
Don''t you think that this is the second most trivial case of ASP.NET, following the most trivial case where you don''t use server-side code at all, only HTML? All server-side Web technologies allow creation of pages from scratch. This is the most basic skill everyone should learn almost from the very beginning.

This is probably the simplest recipe I could think of:

Add a Web page to your ASP.NET Web project. Let''s assume this is the very first page created from the project template called "Default.aspx". The code-behind server-side C# file will be "Default.aspx.cs".

Remove everything from "Default.aspx" except this:
<%@ Page Language="C#" CodeFile="Default.aspx.cs" Inherits="_Default" %>



在"Default.aspx.cs"中,您可以编写:



In "Default.aspx.cs", you can write:

public partial class _Default : System.Web.UI.Page {
    protected void Page_Load(object sender, System.EventArgs e) {
        this.Response.Write("<html><body><h1>Hello, ASP.NET page from scratch!</h1></body><html>");
    }
}



你有主意吗?使用Response.Write,您可以呈现此页面上的任何内容,使用此类中的C#代码,您可能要创建的其他类,您可能要引用的其他程序集进行任何所需的计算—等等.但是,在您的* .aspx页中至少使用HTML框架并在需要的地方使用<%@ ... %>语法添加服务器端代码更为实用.

—SA



Are you getting the idea? Using Response.Write, you can render any content on your page, perform any required calculations using C# code in this class, other classes you may want create, other assemblies you may want to reference — anything at all. However, it''s more practical to use at least HTML skeleton in your *.aspx pages and add server-side code using <%@ ... %> syntax where you need it.

—SA


这篇关于动态创建网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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