This question is locked. New answers and comments are not allowed.
I'm using the Telerik MVC extensions (version 2011.2.712.340). I have a page with a grid to manage Contacts on it that uses a UserControl for the Editor.
I've got it working, but I wanted to add some functionality that would allow the user to select a past Contact from their history. I can't seem to figure out how to access the data of the model passed to the User Control.
Here's what I currently have:
I'd like to end up with a conditional drop down at the top that would appear if it is an insert, but disappear if it is an edit of an existing contact. The code would look something like this:
I've tried a number of different ways to access the data, but can't seem to find anything that will give the ID. Any recommendations on the Syntax to get the value that is being passed?
I've got it working, but I wanted to add some functionality that would allow the user to select a past Contact from their history. I can't seem to figure out how to access the data of the model passed to the User Control.
Here's what I currently have:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<DART.Models.Contact>" %> <% =Html.Hidden("ContactID") %> <div class="CoverSheetFormatting Instruction" style="width:550px;"> <div style="display:table-row;"> <div class="CoverSheetLabel TableHeaderLabel">Title: </div> <div class="CoverSheetData"><%= Html.DropDownList("TitleID", (List<SelectListItem>)(ViewData["TitleList"]))%></div> </div> <div style='clear: both;'></div> <div style="display:table-row;"> <div class="CoverSheetLabel TableHeaderLabel">Contact Type: </div> <div class="CoverSheetData"><%= Html.DropDownList("ContactTypeID", (List<SelectListItem>)(ViewData["ContactTypeList"]))%></div> </div> <div style="display:table-row;"> <div class="CoverSheetLabel TableHeaderLabel">First Name: </div> <div class="CoverSheetData"><%= Html.TextBox("FirstName")%></div> </div> <div style="display:table-row;"> <div class="CoverSheetLabel TableHeaderLabel">Last Name: </div> <div class="CoverSheetData"><%= Html.TextBox("LastName")%></div> </div> <div style="display:table-row;"> <div class="CoverSheetLabel TableHeaderLabel">Email: </div> <div class="CoverSheetData"><%= Html.TextBox("Email")%></div> </div> <div style="display:table-row;"> <div class="CoverSheetLabel TableHeaderLabel">Phone: </div> <div class="CoverSheetData"><%= Html.TextBox("Phone")%></div> </div> <div style="display:table-row;"> <div class="CoverSheetLabel TableHeaderLabel">Fax: </div> <div class="CoverSheetData"><%= Html.TextBox("Fax")%></div> </div> </div>I'd like to end up with a conditional drop down at the top that would appear if it is an insert, but disappear if it is an edit of an existing contact. The code would look something like this:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<DART.Models.Contact>" %> <% =Html.Hidden("ContactID") %> <div class="CoverSheetFormatting Instruction" style="width:550px;"> <% if(Model.ContactID == 0) {%> <div style="display:table-row;"> <div class="CoverSheetLabel TableHeaderLabel">Past Contact:</div> <div class="CoverSheetData"><%= Html.DropDownList("ContactID", (List<SelectListItem>)(ViewData["MrPastContacts"]))%></div> </div> <%}%> <div style="display:table-row;"> <div class="CoverSheetLabel TableHeaderLabel">Title: </div> <div class="CoverSheetData"><%= Html.DropDownList("TitleID", (List<SelectListItem>)(ViewData["TitleList"]))%></div> </div> <div style='clear: both;'></div> <div style="display:table-row;"> <div class="CoverSheetLabel TableHeaderLabel">Contact Type: </div> <div class="CoverSheetData"><%= Html.DropDownList("ContactTypeID", (List<SelectListItem>)(ViewData["ContactTypeList"]))%></div> </div> <div style="display:table-row;"> <div class="CoverSheetLabel TableHeaderLabel">First Name: </div> <div class="CoverSheetData"><%= Html.TextBox("FirstName")%></div> </div> <div style="display:table-row;"> <div class="CoverSheetLabel TableHeaderLabel">Last Name: </div> <div class="CoverSheetData"><%= Html.TextBox("LastName")%></div> </div> <div style="display:table-row;"> <div class="CoverSheetLabel TableHeaderLabel">Email: </div> <div class="CoverSheetData"><%= Html.TextBox("Email")%></div> </div> <div style="display:table-row;"> <div class="CoverSheetLabel TableHeaderLabel">Phone: </div> <div class="CoverSheetData"><%= Html.TextBox("Phone")%></div> </div> <div style="display:table-row;"> <div class="CoverSheetLabel TableHeaderLabel">Fax: </div> <div class="CoverSheetData"><%= Html.TextBox("Fax")%></div> </div> </div>I've tried a number of different ways to access the data, but can't seem to find anything that will give the ID. Any recommendations on the Syntax to get the value that is being passed?