Search code examples
asp.net-mvcasp.net-mvc-4updatepanel

using update panel in ASP.NET MVC 4


Please explain me how to create update panel in ASP.NET MVC4 application. I looked for many blogs... but can not find any useful way. This is my view enter image description here

How I can separate these actions in same view?


Solution

  • Your two panels don't allow the user to switch between one or the other so I assume that you have an "intro" view with the option to either Sign in or Register. Right? In that case there is no real need for client side panel switching using Javascript/Ajax. Your "intro" view can pass a parameter to the controller action defining whether it needs a Sign In or Register view back.

    For instance:

    // 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
    }