RenderView issue in MVC Preview 2

Last post 03-13-2008 3:59 AM by kombatsanta. 8 replies.

Sort Posts:

  • RenderView issue in MVC Preview 2

    03-12-2008, 5:38 AM
    • Member
      6 point Member
    • kombatsanta
    • Member since 03-07-2008, 10:18 AM
    • Posts 8

    I've ben following Scott Guthrie's tutuorials on how to build a MVC app, bt some tings he did back then doesn't really work anymore. E.g:

    <%= Html.ActionLink(category.CategoryName, new { action="List", category.CategoryName}) %>

    I figured this one out myself (yey!) and instead I used:

    <%= Html.ActionLink(category.CategoryName,"List", new { Controller="Products", category=category.CategoryName })%>

    no worries, perfectly logical.. But something I havn't found a replacement for is(in the controller):

    RedirectToAction(new { Action = "Category", ID = product.CategoryID });

    I see that I can  redirect to an action with :

    RedirectToAction("Category");

    and even another controller with;

    RedirectToAction("Category","Products") and also something strange that takes a

    RedirectToAction(System.Web.Routing.RouteVauleDictionary) parameter (whatever that is)

    So how would you now redirect to an action and pass a parameter?

  • Re: RenderView issue in MVC Preview 2

    03-12-2008, 9:17 AM
    • Contributor
      7,054 point Contributor
    • rjcox
    • Member since 12-19-2007, 2:14 PM
    • Basingstoke, UK
    • Posts 1,444

     Preview #2 is rather different to #1.

    You want RedirectToAction(RouteValueDictionary values).

    And just add values with keys like "action", "controller"... to values. 

    Richard
  • Re: RenderView issue in MVC Preview 2

    03-12-2008, 9:40 AM
    • Member
      6 point Member
    • kombatsanta
    • Member since 03-07-2008, 10:18 AM
    • Posts 8

    Ok it worked.. but it's not a pretty solution:

    RedirectToAction(new System.Web.Routing.RouteValueDictionary(new { Action = "List", category = product.Category.CategoryName }));

    Coming from Ruby On Rails I would have prefered passing an argument hash directly:

    RedirectToAction("List", {category => product.Category.CategoryName});

    Also... where are all the nifty "RenderPartial(test.aspx)", "RenderText("hello")" methods? I'm using the render_partial method in RoR heavily when using AJAX calls and ofc the render_text method for manually checking that parameter values are correct from the view to the controller, like: render_text(params["myParam"].value).

    If something like that exists (or will exist in the near future), I might even consider swapping sides from RoR to ASP.NET ;)

     

  • Re: RenderView issue in MVC Preview 2

    03-12-2008, 9:48 AM
    • Contributor
      7,054 point Contributor
    • rjcox
    • Member since 12-19-2007, 2:14 PM
    • Basingstoke, UK
    • Posts 1,444

    kombatsanta:

    Also... where are all the nifty "RenderPartial(test.aspx)", "RenderText("hello")" methods?

     

    Have you tied to look for yourself (Reflector's search function is great for this kind of thing)? 

    Richard
  • Re: RenderView issue in MVC Preview 2

    03-12-2008, 10:22 AM
    • Member
      102 point Member
    • raffaeu
    • Member since 12-04-2006, 1:54 PM
    • Italy
    • Posts 38

    This is the new implementation:

                RedirectToAction(new RouteValueDictionary(new { Controller = "Ticket", Action = "Dettaglio", Id = nuovoTicket.Id }));
     

    Raffaele Garofalo
    MCAD, MCPD
    raffaeu[at]raffaeu[dot]com
  • Re: RenderView issue in MVC Preview 2

    03-12-2008, 10:35 AM
    • Member
      6 point Member
    • kombatsanta
    • Member since 03-07-2008, 10:18 AM
    • Posts 8

    rjcox:

    Have you tied to look for yourself (Reflector's search function is great for this kind of thing)? 

     

     

    Actually: yes, yes I have. Even used Lutz Roeder's .NET Reflector tool and added all the dll's in the "Microsoft ASP.NET MVC Preview 2\Assemblies" to it. So if they exist they are well hidden, and if they have existed they are not included in the MVC Preview 2 framework anymore.

     And yes I'm totally new to the whole .NET Microsoft world (heck.. I don't even own a PC with Windows installed on it @home, using a MAC with leopard for my personal use, just started a new job where they only use MS products and was "forced" to leave the OpenSource world behind me)

     And yes, I can take a hint and will stop bugging you all with my noobish questions now

  • Re: RenderView issue in MVC Preview 2

    03-12-2008, 11:05 AM
    • Contributor
      7,054 point Contributor
    • rjcox
    • Member since 12-19-2007, 2:14 PM
    • Basingstoke, UK
    • Posts 1,444

    kombatsanta:
     And yes, I can take a hint and will stop bugging you all with my noobish questions now
     

    More of a hint that saying that you had tried to find them yourself would have helped (we're all new to Preview #2).

    Richard
  • Re: RenderView issue in MVC Preview 2

    03-12-2008, 4:58 PM
    Answer
    • Participant
      846 point Participant
    • robconery
    • Member since 02-23-2005, 10:16 PM
    • Posts 192
    • AspNetTeam

     RenderPartial == RenderUserControl

  • Re: RenderView issue in MVC Preview 2

    03-13-2008, 3:59 AM
    • Member
      6 point Member
    • kombatsanta
    • Member since 03-07-2008, 10:18 AM
    • Posts 8

    Ah! Sweet!

    Now I just got to fiure out how to use it. Would be great in the future to have something simple like a RenderPartial(string path, RouteValueDictionary values) and a RenderText(string text). 

    The RenderPartial should also be usable from a view so it would be possible to perhaps re-use some code like an input form or something.

    Just wishful thinking here 

Page 1 of 1 (9 items)