提交表单时可以创建新的aspx文件吗?

时间:2014-11-05 18:21:36

标签: asp.net

我公司目前每月举办几次网络研讨会,我们将人们引导到网络研讨会,将他们发送到网站上的默认页面,然后转发到当天为网络研讨会设置的页面。这意味着手动创建页面,然后更改默认页面上的重定向。我想创建一个应用程序,允许CS部门的某个人从即将举行的网络研讨会列表中进行选择。来自数据库的信息被写入另一个收集网络研讨会信息的页面(密码,URL和页面名称,以及供与会者下载的上传材料)。提交时我想创建重定向到的页面(即webinar_11514.aspx)。

如何在提交表单时创建一个全新的文件,并将表单中的所有信息发布到该页面?

2 个答案:

答案 0 :(得分:0)

根据您的描述,CMS即将推出,但您仍处于决策阶段。你现在需要的东西会阻止你,直到CMS到位。

我会使用一些主页并将用户锁定为模板化页面。当CMS到位时会发生这种情况,您现在也可以为它做好准备。您可以在数据库中使用类似XML的内容来设置此类型的页面并使其可自定义。内容可变,但表单和按钮功能之类的内容应该在所有页面中保持一致。 (你需要弄清楚什么是常数与变量)

如果你的环境中有很多东西看起来不同,那么你将不得不将其锁定。 CMS进入后,您的模板就成了选项。期。 (除非页面是在CMS之外创建的,这可能并且确实发生了)

答案 1 :(得分:0)

通常,数据用户界面应用程序逻辑分开。

ASPX页面是您的UI。它控制着您查看数据的方式。 ASPX文件本身应该更改以响应数据。它们应该是静态的。

不是为每个网络研讨会(在运行时)创建像webinar_11514.aspx这样的页面,而应该只创建一个webinar.aspx页面(在设计时)。您可以通过传递查询字符串参数来告诉它要显示哪个网络研讨会,例如:webinar.aspx?id=11414。您的Page_Load函数将检索该信息并决定如何处理它。

protected void Page_Load(object sender, EventArgs e)
{
    //check to see if an ID was provided
    if(String.IsNullOrEmpty(Request.QueryString["id"]))         
    {
    //redirect the user to a page where they can select the webinar, or to an error page, or the home page
    }
    string id = Request.QueryString["id"]; //This will get the 11514 id from the URL.
    var webinar = Webinar.LoadById(id); //load the details of the webinar from a database. It doesn't have to be a relational database, it could be XML or JSON files stored in your ~/App_Data folder. You'll probably want to verify that the webinar for the given ID exists before actually pulling it
    if(!webinar.IsCurrent)
    {
    //tell the user the specified webinar is closed, perhaps redirect to an error page
    }

    //Begin loading UI elements with the details of the webinar
    WebinarTitleLbl.Text = webinar.Title; 
    WebExHyperLink.NavigateUrl = webinar.WebExUrl;
}

如果您使用FriendlyURL's包,则可以使网址更加清晰。您可以使用webinar.aspx?id=11514而不是webinar/11514。您可以使用通过友情网址提供的细分属性,而不是使用查询字符串。告诉别人去mysite.com/webinar/11514mysite.com/webinar.aspx?id=11514要容易得多。它对搜索引擎来说也更好。

相关问题