asp.net-mvc - 在 ASP.NET MVC 4 中使用更新面板

标签 asp.net-mvc asp.net-mvc-4 updatepanel

请解释一下如何在 ASP.NET MVC4 应用程序中创建更新面板。我找了很多博客...但找不到任何有用的方法。 这是我的看法 enter image description here

如何在同一个 View 中分离这些操作?

最佳答案

您的两个面板不允许用户在其中一个或另一个之间切换,因此我假设您有一个“介绍” View ,可以选择登录或注册。正确的?在这种情况下,实际上不需要使用 Javascript/Ajax 进行客户端面板切换。您的“介绍” View 可以将参数传递给 Controller ​​操作,定义它是否需要登录或注册 View 。

例如:

// RouteConfig.cs
routes.MapRoute(
    name: null,
    url: "login-register/{action}",
    defaults: new { controller = "Authentication"},
    constraints: new { action = @"(SignIn|Register)" }
);

// AuthenticationController.cs
public ActionResult SignIn() 
{
    ...
    return View(); // Will return the Authentication\SignIn.cshtml view
}

public ActionResult Register()
{
    ...
    return View(); // Will return the Authentication\Register.cshtml view
}

关于asp.net-mvc - 在 ASP.NET MVC 4 中使用更新面板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15850875/

相关文章:

c# - 为什么我的更新面板不起作用?

javascript - 禁用按钮不会在 UpdatePanel 中提交回发

c# - 在 UpdatePanel 之外更改 TextBox 中的文本

c# - MVC3 应用程序中的本地化

javascript - 将 html 渲染到 View MVC

asp.net-mvc-4 - 处理注入(inject)的 HttpClient

c# - 如何在 Razor View 中指定全局 MVC 布局而不指定布局路径

asp.net-mvc - 对自定义 MVC html 控件使用分部 View

asp.net-mvc - ASP.NET MVC 安全检查表

c# - 在 ASP MVC 中获取变量数量未知的发布数据