corey toolis
corey toolis

Reputation: 13

Redirecting after submit from partial view

This here is my partial view

   @model OpenRoad.Web.Areas.Marketing.Models.AgreementModel


     <script type="text/javascript">
         $(document).ready(function () {

             $('#agreementcheckbox').change(function () {
                 if (this.checked) {
                     $('#btn_next').show();
                 }
                 else {
                     $('#btn_next').hide();
                 }
             });
         });

     </script>


@using Telerik.Web.Mvc.UI;
@using (Html.BeginForm("Agreement", "LeadPipes",FormMethod.Post)) 
{
    @Html.HiddenFor(m=>m.SiteId);
     @Html.HiddenFor(m=>m.Email);
    @Html.HiddenFor(m => m.CountyID);
    @Html.HiddenFor(m => m.HasNationWideLeadpipes);
    @Html.HiddenFor(m => m.Time);
     @Html.HiddenFor(m=>m.LeadType);

<h2>Agreement</h2>
<p>I agree to make sure that all of my communication will be in compliance with both federal and state regulations governing securities.  I acknowledge that it is against federal and state Securities and Exchange Commission laws to solicit loans in an improper manner.  Prior to using Realeflow to download various potential private investor leads, I agree that I am fully liable and responsible for knowing the laws of my state as well as the federal SEC laws.  I will not hold Realeflow, LLC responsible in any way for my violation of those laws.
</p>
    <br />
<span><input type="checkbox" id="agreementcheckbox" /> I have read and acknowledge the compliance.</span>
<div id="btn_next" hidden="hidden">
<span class="btn_add"><input type="submit" value="Next" id="btnSubmit"/></span>

</div>
}

and this is the controller but it will not let me redirect to the page i have listed in the code. Could someone please explain to me how to correctly have it redirect to the pages listed.

[HttpPost]
        public ActionResult Agreement(Models.AgreementModel model)
        {
            if (model.LeadType != null)
            {                
                return Redirect("~/List?hasNationWideLeadPipes=" + model.HasNationWideLeadpipes + "&leadtype=" + model.LeadType);
            }
            else return Redirect("~/List");

        }

THanks

Upvotes: 0

Views: 473

Answers (1)

Chris Pratt
Chris Pratt

Reputation: 239250

For one, don't hard-code the URLs. Instead:

return RedirectToAction("List", new {
    hasNationWideLeadPipes = model.HasNationWireLeadpipes,
    leadtype = model.LeadType
});

Let the routing framework do what it's designed to do.

Upvotes: 1

Related Questions