Copied to clipboard

Flag this post as spam?

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


  • Sylvester 6 posts 87 karma points
    Apr 28, 2016 @ 06:10
    Sylvester
    0

    How to pass values from one page to another without using Querystring

    Hi,

    I have a requirement to pass few color code values from one page to another. How do i do it without passing the values in the URL?

    In the parent page, I have a list of brand names, each brands has its own color codes. So when i click the link of any particular brand, I am redirecting to a common page where I have to update text heading, sub menu back ground color based on the brand name click.

    Can I use macro to set values in parent page and read it in the sub page? or Is there any other way?

    would be good, if i get some sample piece of code.

  • Martin 114 posts 313 karma points
    Apr 28, 2016 @ 07:34
    Martin
    0

    Hi,

    I am not sure of your exact needs but one idea would be to use javascript and store information using cookies. Sorry I have no sample code though.

    Good luck,

    /Martin

  • Micha Somers 134 posts 597 karma points
    Apr 28, 2016 @ 08:03
    Micha Somers
    0

    Instead of a GET, is it possible for to try using a POST?

    There are several ways of passing data with a POST (with MVC, JavaScript, AngularJS, etc. ...)

    Using a Form you could send parameters as hidden fields. If the submit action of that form calls your MVC controller, having something like:

    [HttpPost]
    public ActionResult YourAction(int brandId) {...}
    

    Instead of a Form, you could also try using a JavaScript Ajax call to pass data:

    $.ajax({
        type: "POST",
        url: '@Url.Action("...", "...")',
        data: { brandId: @brand.Id },
        success: function (data) {
            //do stuff
        }
    });
    
  • Manish 373 posts 932 karma points
    Apr 28, 2016 @ 11:46
    Manish
    0

    Create a partial view and call like that

    @Html.Partial("MyPartial", valueModel)

    and in partial

    ................................ @model valueModel

    @{

        var pageUrl = Request.Url.AbsoluteUri;
    
    }
    
    <!-- ---------------------------------------------------------------------- -->
    
    <section class="form">
        <div class="content-wrap flush--ends">
    

    @valueModel.whatever

  • Sylvester 6 posts 87 karma points
    Apr 29, 2016 @ 11:15
    Sylvester
    0

    Hi Manish,

    Could you please expalin in details. I couldn't get your information. Both my parent page and sub page are Umbraco pages.

    homepageTemplate.cshtml

    <ul>
    <li><a href="/subpage/">Brand1</a></li>
    <li><a href="/subpage/">Brand2</a></li>
    <li><a href="/subpage/">Brand3</a></li>
    </ul>
    

    childpageTemplate.cshtml

    <h1>heading text</h1>
    foreach (var childPage in CurrentPage.Children.Where("hideInNavigation==false"))
    {
        <div>
             <a href="@childPage.Url">@childPage.Name</a>                              
        </div>
    }
    

    here subpage is following "childpageTemplate" template and clicking any brand will redirect to "childpageTemplate.cshtml". so in that template i should get few values(brand name, title color menubgcolor) related to Brand which is clicked.

Please Sign in or register to post replies

Write your reply to:

Draft