MVC LOB Application
I am new to web development and I am starting with an MVC project. I have an idea of creating a new service. In this view, I need to have a button to show a dialog with customer names (I would also like to implement filters and paging in this dialog). When the user selects a client from the dialog, I need to fill in some combo boxes in the service view with information regarding that particular client. How can i do this? If you have any demo code or tutorial, can I learn how to do this?
Thanks in advance for any feedback.
a source to share
I recommend reading Pro ASP.NET MVC Framework by Steven Sanderson .
Phil Haack , Stephen Sanderson, and the Stephen Walter Blog are also good resources.
a source to share
Just enough to answer in one question.
I think you need to try the NerdDinner sample first to get a family environment with an MVC framework.
Then jQuery will become your friend. Essentially, you can create a dialog with a jQuery call and use jQuery Ajax calls to your controller to get and filter the data.
A good link for jQuery is at jQuery.com
a source to share
(griegs I cannot comment on your answer because the post is too long)
I use TailSpin Travel as a bible.
I have doubts that maybe you can clarify.
Change view
(...)
<div id="clientSearch">
<%= Html.DropDownList("clientId", Model.Clients, Model.Clients)%>
<div class="resultsWrapper">
<div class="results">
<% Html.RenderPartial("clientDetails", Model); %>
</div>
</div>
</div>
(...)
Customer details partial view
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<EyePeak.ViewModel.Service.EditServiceViewModel>" %>
<% if(Model.SelectedClient != null) { %>
<tr>
<%Html.LabelFor(model => model.SelectedClient.Name);%>
<%= Html.DropDownList("clientAddresses", Model.SelectedClient.Addresses.Select(i => new SelectListItem { Value = i.Id.ToString(), Text = i.Name}))%>
</tr>
<% } %>
Controler:
(...)
public ActionResult New()
{
var service = new EyePeak.Data.Model.Service();
return View("Edit", this.GetEditViewModel(service));
}
(...)
public ActionResult SearchClientAddresses(string clientID)
{
var selectedClient = this._clientService.GetClient(Convert.ToInt32(clientID));
var model = new EditServiceViewModel
{
SelectedClient=selectedClient
};
return PartialView("clientDetails", model);
}
JQuery
Sys.Application.add_load(
function()
{
$("#clientId").bind("change", showClientInfo);
}
);
function showClientInfo()
{
var id = $("#clientId").val();
$("#clientSearch .results table").fadeOut();
$("#clientSearch .results").slideUp("medium", function() {
$.ajax(
{
type: "GET",
url: "/Service/SearchClientAddresses",
data: "clientID=" + escape(id),
dataType: "html",
success: function(result) {
var dom = $(result);
$("#clientSearch .results").empty().append(dom).slideDown("medium");
}
});
});
}
My question is, should I create a new EditServiceViewModel with only Client information in order to pass it to the partial view? Can't I update the current ViewModel and pass it to the partial view?
I need to create more partial views along the way in that particular view, so I need to create a view model for each?
I may not have understood this concept well.
Thanks again for your help.
a source to share