0

Mvc4 with 2 controllers

From the image i try to load two controllers, on pageload Browse controller loads with 1 and 2 data from picture, when i want to select the date,it should load the dayselect controller data in same page. How can i do this , My controllers are here

public ViewResult Browse(Int32 eventid) {
//code
return view(ef);
}

public ActionResult DaySelect(EventModel m) {
return view("_Common",k);
} 

My viewModel for Browse Controller is Browse.cshtml

@model BrowseEventModel

<div class="Event_Name" id="id_name">@Model.EventName</div>

<div class="Event_loc" id="id_loc">@Model.EventLocation</div>

//In this view i have a widget which i load in partial view

<div class="yui3-g" id="bottom_container"> @{Html.RenderPartial("_Common");}

</div>

The partial view is _common.cshtml

@model BrowseEventModel
<select name="dayNo" id="dayNo">
@foreach (var s in Model.Dayselector) {
<option value = "@s.DayNo"> @s.DayDate.ToString("dd MMM yyyy")</option>
}
</select>

//View Model used for both browse and dayselect controller

@foreach(var e in Model.DisplayData){    
<ul id="ul-data">@e.dataName</ul>
<div id="ul-id">@e.dataid</div> 
}

When i select the date it should load data in same view page is it possible,i.e injecting view on runtime

Jason Evans
  • 28,906
  • 14
  • 90
  • 154
Mazher
  • 91
  • 3
  • 13

1 Answers1

1

You can use AJAX to inject view at runtime. In your case, you are depending on the onchange event of a DropDownList. A question has already been asked with the same problem as yours. Try this: using ajax with dropdownlist mvc3

Community
  • 1
  • 1
rajeemcariazo
  • 2,476
  • 5
  • 36
  • 62