Iria
Iria

Reputation: 17

can I have a fieldset in razor with 2 parameters?

I have an old razor page in a 4.8 Net framework project. I have a datepicker for a input start date already, and I need to add another one for the end date. The end date has to be in the same row than the start date, and the end date values depend on the start date values.

I also have a model with both properties and there is some jquery code that links to the razor page and does some validations. I am trying to send the old value (start date) and the new value (end date) to a controller.

The problem: only one value gets updated and I need both.

The following code only adds the EndDate and not the StartDate

<fieldset data-bind="visible : ShowStartDate()">
            <legend>@Html.DisplayNameFor(x => x.StartDate)</legend>
            <div class="row">
                <div class="column">
                    <div>
                        <div class="sixteen columns add-pad-top half-bottom">
                            @mandatoryFieldLabelText("Effective Start date")
                            <input aria-label="date" type="text" id="StartDate" data-bind="value: StartDate" name="StartDate" placeholder="dd/mm/yyyy" disabled="disabled" size="10" maxlength="10" style="margin-left:0px;" />
                        </div>
                    </div>
                </div>
                <div class="column">
                    <div id="div2">
                        <div class="sixteen columns add-pad-top half-bottom">
                            @mandatoryFieldLabelText("Effective End date")
                            <input aria-label="date" type="text" id="EndDate" name="EndDate" data-bind="value: EndDate" placeholder="dd/mm/yyyy" size="10" maxlength="10" style="margin-left:0px;" />
                        </div>
                    </div>
                </div>
            </div>
        </fieldset>

In other area of the code, I have the following:

` startDateOb = ko.observable(startDate.toString() === '01/01/0001' ? '' : startDate.toString()),

        endDateOb = ko.observable<string>(endDate.toString() === '01/01/0001' ? '' : endDate.toString()),`

So the previous will give me only the endDate but not the startDate, the startDate will be set to 01/01/0001

I was expecting to be able to get both dates

Upvotes: 1

Views: 53

Answers (0)

Related Questions