在 ASP.NET MVC 2 中使用配置文件和 CreateUserwizard

发布于 2024-09-05 22:25:27 字数 338 浏览 3 评论 0原文

我正在使用 本教程 在中创建应用程序ASP.NET MVC 2,我可以使用 CreateUserWizard 控件注册具有自定义配置文件属性的用户。

我的问题是本教程使用 ASP.NET(不是 MVC),并且需要控件的代码隐藏来处理 CreateUserWizard1_CreatedUser 方法。

由于 ASP.NET MVC 视图默认没有隐藏代码,我想知道如何访问该方法。

预先感谢,萨姆。

I am using this tutorial to create an application in ASP.NET MVC 2 where I can register users with custom profile properties using the CreateUserWizard control.

My problem is that the tutorial uses ASP.NET (not MVC) and it needs the code-behind of the control for handling the CreateUserWizard1_CreatedUser method.

Since in ASP.NET MVC Views don't have a code-behind by default, I would like to know how can I have access to that method.

Thanks in advance, Sam.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

烏雲後面有陽光 2024-09-12 22:25:27

看起来 CreateUserWizard 是一个标准的 ASP.Net 控件,因此无法在 MVC 中工作。您可以从 MVC 视图引用标准 ASP.Net 控件,但它们具有的任何依赖于 ViewState 或 PostBack 的功能都不起作用,因为 MVC 中不存在这两个概念。

话虽如此,可以在同一应用程序中运行 ASP.Net WebForms 和 ASP.Net MVC,因此,如果您想使用 Webforms 创建此功能,您可以这样做,然后只需链接到用于创建用户的网络表单页面。

查看 Scott Hanselman 的这篇博客文章,讨论运行 ASP.Net MVC, WebForms 和 ASP.Net 动态数据位于同一应用程序中。

It looks like the CreateUserWizard is a standard ASP.Net control, and therefor is not going to work in MVC. You can reference standard ASP.Net controls from MVC views, but any functionality they have that relies on ViewState or PostBack is not going to work, since neither of those concepts exist in MVC.

That being said, it is possible to run ASP.Net WebForms and ASP.Net MVC within the same application, so if you wanted to create this functionality using webforms, you could do that, and simply link to the webforms page to do your user creation.

Have a look at this blog post from Scott Hanselman talking about running ASP.Net MVC, WebForms, and ASP.Net Dynamic Data in the same application.

余生一个溪 2024-09-12 22:25:27

您还可以创建类似向导的 ASP.NET MVC 模式,如下所述:

http:// www.highoncoding.com/Articles/647_Creating_Wizard_Using_ASP_NET_MVC_Part_1.aspx
http://www.highoncoding.com/Articles/647_Creating_Wizard_Using_ASP_NET_MVC_Part_1.aspx

使用 MVC2,但是,您会遇到部分模型验证的问题。可以通过为每个页面使用单独的 ViewModel 或使用 ActionFilters 来解决此问题,如下所述:

http://blog.stevensanderson.com/2010/02/19/partial-validation-in-aspnet-mvc-2/

You could also create a wizard-like ASP.NET MVC pattern, as described here:

http://www.highoncoding.com/Articles/647_Creating_Wizard_Using_ASP_NET_MVC_Part_1.aspx
http://www.highoncoding.com/Articles/647_Creating_Wizard_Using_ASP_NET_MVC_Part_1.aspx

With MVC2, however, you will have a problem with partial model validation. It can be solved by using a separate ViewModel for every page, or by using ActionFilters as described here:

http://blog.stevensanderson.com/2010/02/19/partial-validation-in-aspnet-mvc-2/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文