如何动态创建 ASPX 页面
我在 ASP.NET 页面上有两个控件,文本框和按钮,我想将新页面写入文本框,然后当我点击按钮时,我想使用文本框文本创建新的 ASP.NET 网页。你想让我更喜欢做什么?是否有任何分步教程或您之前完成过的任何代码?感谢您的解答。
好的,关于我想要的更多细节。
文本框控件文本是“联系人”,我单击按钮控件。按钮采用文本框文本“contact”并创建新的 Web 表单页面,其名称为“contact.aspx 及其代码页 contact.cs”。就是这样。只需单击按钮在根目录下创建新的 Web 表单页面即可。
也许有一个代码行,例如
Page pg =new Page(); pg.create();
i have two controls on asp.net page , textbox and button and i want to write new page into textbox then when i hit the button i want to create new asp.net web page with textbox text. what do you want me to prefer to do this? is there any step by step tutorial or any code you have done before? thanks for asnwers.
ok more detail about what i want.
textbox control text is "contact" and i click my button control. button take textbox text "contact" and create new web form page which name is "contact.aspx and its code page contact.cs" . thats it. just create new web form page under root directory with button click.
maybe there is a single code line like
Page pg =new Page();
pg.create();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以使用
File.WriteAllText
将文本框的内容写入应用程序池用户有权写入的任何位置。从您的编辑来看,您似乎正在寻找 CMS/wiki 类型的功能。 .NET 框架中没有内置类似的东西。
我建议你寻找wiki软件。
You can use
File.WriteAllText
to write the contents of the textbox to any location that the application pool user has permissions to write to.From your edit it appears that you are looking for a CMS/wiki kind of functionality. There is nothing like that built into the .NET framework.
I suggest you look for wiki software.
无需担心大代码等
您可以通过我的博客中解释的 2 个简单步骤创建它
请访问我的博客以获取示例解决方案
单击此处查看解决方案帖子
No need to worry about big codes etc
You can create it with 2 simple steps explained in my blog
Please visit my blog for example solution
Click here for Solution Post
您可以使用 Page.ParseControl方法。
请注意,它并不支持您使用真正的 ASPX 或 ASHX 文件执行的所有操作,但它适用于简单的事情。此处提供了一个示例:使用 Page.ParseControl 从 Control Tag 添加新控件
You can use the Page.ParseControl method.
Beware, it does not support everything you can do with a real ASPX or ASHX file, but it works for simple things. An example is available here: Using Page.ParseControl to add new control from Control Tag
有一个非常简单的方法可以做到这一点。复制一个页面的原则是,您应该将页面与要在其他页面上使用的控件放在一起。因此,首先您需要
using System.IO;
然后您需要此代码如您所见,您正在处理的页面称为 Submit,并且页面的新名称称为 textbox1.text。
我希望这对您和其他人有所帮助。
There is very simple way to do that. It is working on principe to Copy one your Page, you should put Page with controls that you want to use on your other pages. So first you need
using System.IO;
then you need this codeAs you can see, The page you are coping is called Submit, and new Name of your Page is called like textbox1.text.
I hope that this helped you and anyone else.