-1

I am having some problems solving this. The thing is, this is the only place it doesn't work, everywhere else in my project it works just fine and it's all the same.

here is my link:

<td class="col-sm-1 col-lg-1">@Html.ActionLink("Edit", "EditGrowWeek", "FinishedProductionMaintanance", new { @id = Model.growWeek.GWID }, new { @data_toggle = "modal", @data_target = "#editGrowWeek" })</td>

my controller:

    [HttpGet]
    public ActionResult EditGrowWeek(int id)
    {
        viewModel.growWeek = _ProductionGrowWeekRepository.GetOne(id);
        return PartialView(viewModel);
    }

    [HttpPost]
    //[ValidateAntiForgeryToken]
    public ActionResult EditGrowWeek([Bind(Prefix="growWeek")] ProductionGrowWeek growWeek)
    {
        var growWeeks = _ProductionGrowWeekRepository.GetAll(growWeek.GProfileNo);
        foreach (var week in growWeeks)
        {
            if (ModelState.IsValid)
            {
                _ProductionGrowWeekRepository.Edit(week);
            }
        }
        return RedirectToAction("IndexGrowProfiles");
    }

and finally my view:

@model SISCOM.ViewModel.FinishedProductionMaintananceViewModel
@{
    Layout = null;
}

<div class="modal fade in" id="editGrowWeek" tabindex="-1" role="dialog" aria-labelledby="MyModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dissmiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            </div>
            <div class="modal-body">
                @using (Html.BeginForm("EditGrowWeek", "FinishedProductionMaintanance", FormMethod.Post))
                {
                    @*@Html.AntiForgeryToken()*@
                    <form id="form">
                        @Html.ValidationSummary(true)
                        @Html.HiddenFor(model => model.growWeek.GWID)
                        @Html.HiddenFor(model => model.growWeek.CutSupplierCode)
                        @Html.HiddenFor(model => model.growWeek.DelvyWk)
                        @Html.HiddenFor(model => model.growWeek.Description_ID_)
                        @Html.HiddenFor(model => model.growWeek.Description_Product_)
                        @Html.HiddenFor(model => model.growWeek.Despatch)
                        @Html.HiddenFor(model => model.growWeek.FinishedDuration)
                        @Html.HiddenFor(model => model.growWeek.FinishedSite)
                        @Html.HiddenFor(model => model.growWeek.GapUpHandSite)
                        @Html.HiddenFor(model => model.growWeek.GapUpMCSite)
                        @Html.HiddenFor(model => model.growWeek.GerminationDuration)
                        @Html.HiddenFor(model => model.growWeek.GerminationSite)
                        @Html.HiddenFor(model => model.growWeek.Germinator)
                        @Html.HiddenFor(model => model.growWeek.GerminatorDuration)
                        @Html.HiddenFor(model => model.growWeek.GerminatorSite)
                        @Html.HiddenFor(model => model.growWeek.GProfileNo)
                        @Html.HiddenFor(model => model.growWeek.GrowWks1)
                        @Html.HiddenFor(model => model.growWeek.GrowWks2)
                        @Html.HiddenFor(model => model.growWeek.GrowWks3)
                        @Html.HiddenFor(model => model.growWeek.GrowWks4)
                        @Html.HiddenFor(model => model.growWeek.GrowWks5)
                        @Html.HiddenFor(model => model.growWeek.OrderWK)
                        @Html.HiddenFor(model => model.growWeek.PreGapDuration)
                        @Html.HiddenFor(model => model.growWeek.PreGapSite)
                        @Html.HiddenFor(model => model.growWeek.PrickOut)
                        @Html.HiddenFor(model => model.growWeek.PrickOutSite)
                        @Html.HiddenFor(model => model.growWeek.Priority)
                        @Html.HiddenFor(model => model.growWeek.ProdGrp)
                        @Html.HiddenFor(model => model.growWeek.ProdSeries)
                        @Html.HiddenFor(model => model.growWeek.ProdSeriesDetail)
                        @Html.HiddenFor(model => model.growWeek.ProductionGrowProfile)
                        @Html.HiddenFor(model => model.growWeek.RangeUpdateFlag)
                        @Html.HiddenFor(model => model.growWeek.Rooting_GermAssess)
                        @Html.HiddenFor(model => model.growWeek.SiteGrown)
                        @Html.HiddenFor(model => model.growWeek.SiteRange)
                        @Html.HiddenFor(model => model.growWeek.SiteSown)
                        @Html.HiddenFor(model => model.growWeek.Topping)
                        @Html.HiddenFor(model => model.growWeek.ToppingCode)
                        @Html.HiddenFor(model => model.growWeek.Transplant)
                        <div class="form-group">
                            <div class="editor-label">
                                @Html.LabelFor(p => p.growWeek.WksToDesp, "Weeks to despatch")
                            </div>
                            <div class="editor-field">
                                @Html.TextBoxFor(p => p.growWeek.WksToDesp, null, new { @class = "form-control", @placeholder = "Weeks to despatch" })
                                @Html.ValidationMessageFor(p => p.growWeek.WksToDesp, "", new { @class = "text-danger" })
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="editor-label">
                                @Html.LabelFor(p => p.growWeek.GapUp, "Gap up")
                            </div>
                            <div class="editor-field">
                                @Html.TextBoxFor(p => p.growWeek.GapUp, null, new { @class = "form-control", @placeholder = "Gap up" })
                                @Html.ValidationMessageFor(p => p.growWeek.GapUp, "", new { @class = "text-danger" })
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="editor-label">
                                @Html.LabelFor(p => p.growWeek.Pinch1, "Pinch1")
                            </div>
                            <div class="editor-field">
                                @Html.TextBoxFor(p => p.growWeek.Pinch1, null, new { @class = "form-control", @placeholder = "Pinch1" })
                                @Html.ValidationMessageFor(p => p.growWeek.Pinch1, "", new { @class = "text-danger" })
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="editor-label">
                                @Html.LabelFor(p => p.growWeek.Pinch2, "Pinch2")
                            </div>
                            <div class="editor-field">
                                @Html.TextBoxFor(p => p.growWeek.Pinch2, null, new { @class = "form-control", @placeholder = "Pinch2" })
                                @Html.ValidationMessageFor(p => p.growWeek.Pinch2, "", new { @class = "text-danger" })
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="editor-label">
                                @Html.LabelFor(p => p.growWeek.Space1, "Space1")
                            </div>
                            <div class="editor-field">
                                @Html.TextBoxFor(p => p.growWeek.Space1, null, new { @class = "form-control", @placeholder = "Space1" })
                                @Html.ValidationMessageFor(p => p.growWeek.Space1, "", new { @class = "text-danger" })
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="editor-label">
                                @Html.LabelFor(p => p.growWeek.Space2, "Space2")
                            </div>
                            <div class="editor-field">
                                @Html.TextBoxFor(p => p.growWeek.Space2, null, new { @class = "form-control", @placeholder = "Space2" })
                                @Html.ValidationMessageFor(p => p.growWeek.Space2, "", new { @class = "text-danger" })
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="editor-label">
                                @Html.LabelFor(p => p.growWeek.Space3, "Space3")
                            </div>
                            <div class="editor-field">
                                @Html.TextBoxFor(p => p.growWeek.Space3, null, new { @class = "form-control", @placeholder = "Space3" })
                                @Html.ValidationMessageFor(p => p.growWeek.Space3, "", new { @class = "text-danger" })
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="editor-label">
                                @Html.LabelFor(p => p.growWeek.Check1, "Check1")
                            </div>
                            <div class="editor-field">
                                @Html.TextBoxFor(p => p.growWeek.Check1, null, new { @class = "form-control", @placeholder = "Check1" })
                                @Html.ValidationMessageFor(p => p.growWeek.Check1, "", new { @class = "text-danger" })
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-offset-2 col-md-10">
                                <input type="submit" value="Edit" class="btn btn-default" />
                            </div>
                        </div>
                    </form>
                }
            </div>
        </div>
    </div>
</div>

I've been checking everywhere and this one doesn't make a call at all... any ideeas?

P.S. ... this might be connected so, on this page, (On the index that renders this partial) my footer is being rendered somewhere in the middle of my page in code..

tereško
  • 58,060
  • 25
  • 98
  • 150
Spluf
  • 810
  • 1
  • 11
  • 26
  • When you mouseover the link, is the browser showing a link suitable for your controller and action? Why do you think you need the Bind prefix here? – outofmind Sep 24 '15 at 08:34
  • Looks to me like htmlAttribute and routeValue have to be changed in the link – outofmind Sep 24 '15 at 08:39
  • Unclear what your asking. What is not working? What is the relevance of all that code in the view? (which incidentally wont post because of the invalid nested forms) –  Sep 24 '15 at 08:44
  • yes, i can see a valid link. I prefixed it because i am returning only a part of a bigger model. – Spluf Sep 24 '15 at 08:44
  • Stephen, i mentioned that this doesn't make a call to my controller.. the view is the same as 15 others all around my project (so far) and they all work as they should, except this one... I am checking the debugger, if the form was wrong, it should still call the GET part of that action, and even if the controller or the route value or anything like this was wrong, i should still see a failed call right? But i'm not seeing anything... no calls are made at all from that ActionLink. – Spluf Sep 24 '15 at 08:46
  • what happens if you type the link you see into the adress line of your browser? – outofmind Sep 24 '15 at 09:02
  • outofmind - it takes me to the edit view. – Spluf Sep 24 '15 at 09:05
  • is it what you want? if yes - take a look at the html code generated by the actionlink what's different there – outofmind Sep 24 '15 at 09:07
  • it is, just need it to open in a modal to keep the consistency all over the site. The links look the same, nothing different there except there's no http://localhost:port/ but it's the same all over the site. The strange thing is that if i just take out the layout on the index page everything works.. so it must be something there, but still have no idea what – Spluf Sep 24 '15 at 10:42

1 Answers1

0

This doesn't make a lot of sense but here it is. The problem was that everytime i generated values for that table it removed the partial view following it for some reason (if anyone can make sense of this behaviour and can explain please do.)

so, my index for this page used to look like this:

<div class="tab-content col-md-9 col-lg-9 growProfilePage">
    <div class="col-md-12 col-lg-12">
        <div class="col-md-4">
            @{ Html.RenderPartial("ListGrowProfiles");}
        </div>
        <div class="col-md-8">
            @{ Html.RenderPartial("ListGrowWeeks");}
            @{ Html.RenderPartial("EditGrowWeek");}
        </div>
    </div>
</div>

now it looks like this:

<div class="tab-content col-md-9 col-lg-9 growProfilePage">
    <div class="col-md-12 col-lg-12">
        @{ Html.RenderPartial("EditGrowWeek");}
        <div class="col-md-4">
            @{ Html.RenderPartial("ListGrowProfiles");}
        </div>
        <div class="col-md-8">
            @{ Html.RenderPartial("ListGrowWeeks");}
        </div>
    </div>
</div>

and it all works (curiously enough, on other pages it's still like before, the edit following the list and it works like that).

Spluf
  • 810
  • 1
  • 11
  • 26