0

I have a scenario where i need some code setup when a control renders. I have a widget that'll be used on a number of pages called a QuickRate:

I'm trying to call it like so in my cshtml file:

<div class="dragbox" id="quick-rate">
<h2>Retrieve a Quick Rate</h2>
@Html.Action("Create", "QuickRate")
</div>

and then in the create on the QuickRateController.cs I have:

public ActionResult Create()
{
var model = new QuickRateModel();
    model.Products = currentUser.GetProducts(dataRepository).ToSelectList(p => p.ProductId, p => p.ProductName);
return View("QuickRateResult", model);
}

i then have a QuickRatePartial.cshtml file that contains the following:

@model Project.Web.Models.QuickRateModel

@{
    Layout = "";
    AjaxOptions options = new AjaxOptions()
    {
        HttpMethod = "Post",
        UpdateTargetId = "quick-rate-content"
    };
}
<div class="clearfix">
    @using (Ajax.BeginForm("GetQuickRate", "QuickRate", null, options, new { @id="quick-rate-form" }))
 {
        <fieldset>
          @Html.DropDownListFor(model => model.ProductId, Model.Products)
          @Html.ValidationMessageFor(model => model.ProductId)
         <select data-val="true" name="DropDown1" data-bind="
                                options: Items1,
                                optionsText :'ItemName',
                                value: SelectedName
                                ">
                            </select>

        <select data-val="true" name="DropDown2" id="DropDown2" data-val-required="Please select an Item." data-bind="
        options: SelectedItem().MoreItems,
        optionsText: 'Text',
        optionsValue: 'Text',
        value: MoreItem,
        optionsCaption: 'Select One'
        "></select>
        <div class="clearfix">
            @Html.ValidationMessageFor(model => model.MoreItems)
        </div>
        <div>
            <input type="submit" value="Get Quick Rate" />
        </div>
        <div id="quick-rate-content"></div>
        </fieldset>
 }
</div>

try as i might I can't get the form to render at all.. just wondering if you had any suggestions?

Cheers!

1 Answer 1

3

You've named the file quickratepartial.cshtml but in the action you are looking for a view called quickrateresult. Is this correct?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.