Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Robert Foster 459 posts 1820 karma points MVP 3x admin c-trib
    May 30, 2011 @ 01:46
    Robert Foster
    2

    Support for Parameters

    Hi,

    Great package, saved me rolling my own ;)  I've downloaded the source and modified it so that it also supports the Parameter collection in addition to the current Node support.  I could contribute it back to the source if you want me to, my codeplex username is robertjf - otherwise I could just email the changes to you I suppose?

    Rob

  • Richard Boelen 61 posts 153 karma points
    May 30, 2011 @ 08:33
    Richard Boelen
    0

    Thanks Rob,

    I added you to the codeplex project so you can check-in your changes.

    I also noticed that you can only use the RenderMvcAction once because I did not check routedata values for existing keys,

    Next to that I want to be able to have multiple forms in seperated Views. At the moment any postback will call all post methods for all the RenderMvcAction when you have multiple RenderMvcAction on your page. For this I need a way to determine which form trigged the postback. At the moment I am thinking of creating a special form token like the AntiForgeryToken, at the postback I could check for this token and use the GETmethod or the POST method.

    Cheers, Richard

  • Robert Foster 459 posts 1820 karma points MVP 3x admin c-trib
    May 30, 2011 @ 08:46
    Robert Foster
    0

    Hi Richard,

    Noticed that - already checked in the changes ;) Have started experimenting with it, and will likely need to be able to run multiple views on a page, so that functionality is going to be need a must very soon ;) the form token idea seems to be a good viable solution...

    Rob.

  • Richard Boelen 61 posts 153 karma points
    May 30, 2011 @ 09:54
    Richard Boelen
    0

    Hi Rob,

    multiple views are working now and checked in ;-) , man I love TFS

    Working on the form token now. First approach will be adding the token in the RenderMvcAction method..this is the easiest one I think. Another approach would be adding it as an attribute on the controller post action, but that involves reflection.

    Richard

  • Richard Boelen 61 posts 153 karma points
    May 30, 2011 @ 11:11
    Richard Boelen
    0

    Hi,

    I added the support for the multiple forms in seperate Views. The RenderMvcAction needs a formtoken string and you will need to use the HtmlHelper extension RenderFormToken() within your forms.

    All views are now rendered using the HttpGet method from the controller, regardless of the HttpMethod type of the main request. When you do a postback and the form contains the formtoken, it will use the HttpPost method.

    Source is checked-in in codeplex.

    Cheers, Richard

  • Robert Foster 459 posts 1820 karma points MVP 3x admin c-trib
    May 31, 2011 @ 09:14
    Robert Foster
    0

    Hi Richard,

    The current version under source control has broken Parameter support...

    The line

                        ((IMvcBridgeView)viewResult.View).Parameter = Parameter;

    is missing from MvcBridgeController at around line 44 (right next to the Node assignment)...

    Thanks,

    Rob.

  • Richard Boelen 61 posts 153 karma points
    May 31, 2011 @ 09:21
    Richard Boelen
    0

    Thanks! I missed that (or better, didn't test :-( )

    Checked in the changes,

    Cheers, Richard

  • Robert Foster 459 posts 1820 karma points MVP 3x admin c-trib
    May 31, 2011 @ 09:35
    Robert Foster
    0

    Actually, after some testing, seems there's a bit of dud code (lines 42 - 45 in MvcBridgeController.cs):

                    if (viewResult.View is IMvcBridgeView) {
    ((IMvcBridgeView)viewResult.View).Node = Node;
    ((IMvcBridgeView)viewResult.View).Parameter = Parameter;
    }

    the condition is always returning false!

    However, the following is being hit just fine (in MvcBrdigeView.SetViewData()):

                if (this.ViewContext.Controller is IMvcBridgeController) {
    Node = ((IMvcBridgeController)this.ViewContext.Controller).Node;
    Parameter = ((IMvcBridgeController)this.ViewContext.Controller).Parameter;
    }

    - I've added the Parameter line there instead ...

  • Richard Boelen 61 posts 153 karma points
    May 31, 2011 @ 09:39
    Richard Boelen
    0

    As did I :-) I will remove the stuff from the controller. That was the first place I started passing data to the view. I think the controller should be in charge here...but for that to work we would need a custom viewResult. Lets keep it in the SetViewData() for now

Please Sign in or register to post replies

Write your reply to:

Draft