or
//Select List of all cars
public
IEnumerable<System.Web.Mvc.SelectListItem> AllCars
{
get
{
if
(Cars !=
null
)
{
var _sacts = Cars.Select(f =>
new
System.Web.Mvc.SelectListItem
{
Value = f.code,
Text = f.description
});
return
_sacts;
}
else
return
null
;
}
}
public
IEnumerable<CarTypes> Cars {
get
;
set
; }
//Select List of previous saved cars
public
IEnumerable<System.Web.Mvc.SelectListItem> SelectedCars
{
get
{
if
(SelectedCarsValues !=
null
)
{
var _sacts = SelectedCarsValues.Select(f =>
new
System.Web.Mvc.SelectListItem
{
Value = f.code,
Text = f.description
});
return
_sacts;
}
else
return
null
;
}
}
public
IEnumerable<CarTypes> SelectedCarsValues {
get
;
set
; }
@(Html.Kendo().MultiSelectFor(m => m.SelectedCars)
.BindTo(Model.AllCars)
.DataTextField("Text")
.DataValueField("Value")
)
<
script
type
=
"text/x-kendo-tmpl"
id
=
"CarsTemplate"
>
${Text}
</
script
>
@(Html.Kendo().ListView(Model.SelectedCars)
.Name("Cars")
.TagName("p")
.ClientTemplateId("CarsTemplate")
.BindTo(Model.SelectedCars)
)
public IEnumerable<
string
> SelectedCars
{
get
{
if (SelectedCarsValues != null)
{
return SelectedCarsValues.Select(a => a.code);
}
else return null;
}
}
[RegularExpression(@
"([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-zA-Z0-9]{1}[a-zA-Z0-9\-]{0,62}[a-zA-Z0-9]{1})|[a-zA-Z])\.)+[a-zA-Z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)"
, ErrorMessage =
"Not a valid email"
)]
[DataType(DataType.EmailAddress)]
public
string
Email {
get
;
set
; }
<
input
type
=
"text"
value
=
""
name
=
"Email"
id
=
"Email"
data-val-required
=
"Das Feld wird benötigt."
data-val-regex-pattern
=
"([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-zA-Z0-9]{1}[a-zA-Z0-9\-]{0,62}[a-zA-Z0-9]{1})|[a-zA-Z])\.)+[a-zA-Z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)"
data-val-regex
=
"Not a valid email"
data-val
=
"true"
class
=
"text-box single-line"
data-bind
=
"value:Email"
>
<
input
type
=
"text"
value
=
""
name
=
"Email"
id
=
"Email"
data-val-required
=
"Das Feld wird benötigt."
data-val-regex-pattern
=
"([w!#$%&'*+-/=?^`{|}~]+.)*[w!#$%&'*+-/=?^`{|}~]+@((((([a-zA-Z0-9]{1}[a-zA-Z0-9-]{0,62}[a-zA-Z0-9]{1})|[a-zA-Z]).)+[a-zA-Z]{2,6})|(d{1,3}.){3}d{1,3}(:d{1,5})?)"
data-val-regex
=
"Not a valid email"
data-val
=
"true"
class
=
"text-box single-line"
data-bind
=
"value:Email"
>
01.
@model IEnumerable<
SampleViewModel
>
02.
[...]03.
@foreach (var item in Model)
04.
{
05.
<
div
class
=
"form-horizontal"
>
06.
<
div
class
=
"form-group"
>
07.
@Html.LabelFor(modelItem => item.Html, new { @class = "control-label col-md-2" })
08.
<
div
class
=
"col-md-10"
>
09.
@Html.Kendo().EditorFor(modelItem => item.Html).Tools(tools=>tools.ViewHtml()).Encode(false)
10.
</
div
>
11.
</
div
>
12.
</
div
>
13.
} [...]
<
nav
class
=
"navbar navbar-default"
role
=
"navigation"
>
<
ul
class
=
"nav navbar-nav"
>
<
li
>@Html.ActionLink(Resources.NavigationLink_Feedback, "Index", "Feedback", routeValues: null, htmlAttributes: new { @class = "feedbackmodallink" })</
li
>
</
ul
>
</
nav
>
@(Html.Kendo().Window()
.Name("FeedbackWindow")
.Title(Resources.Title_Feedback)
.LoadContentFrom("Index", "Feedback")
.Actions(action => action.Maximize().Close())
.Modal(true)
.Iframe(true)
.Visible(false)
.AutoFocus(true)
.Events(events => events.Refresh("FeedbackWindow_Refresh"))
)
$(document).ready(
function
() {
var
tFeedbackWindow = $(
"#FeedbackWindow"
).data(
"kendoWindow"
);
$(
"a.feedbackmodallink"
).click(
function
(e) {
// Was the middle button clicked?
// (allow link to still be opened in new tab with middle click should user choose)
if
(e.which != 2)
{
// No
e.preventDefault();
// Show feedback modal
MyNameSpace.TelerikWindow.OpenWindow(tFeedbackWindow);
}
});
$(window).resize(
function
(e) {
// Is feedback modal currently visible?
if
(tFeedbackWindow.options.visible) {
// Yes, resize modal to new browser size
MyNameSpace.TelerikWindow.ResizeWindow(tFeedbackWindow);
}
});
});
function
FeedbackWindow_Refresh() {
// Resize window to content
MyNameSpace.TelerikWindow.ResizeWindow(
this
);
}
MyNameSpace.TelerikWindow = {
OpenWindow:
function
(tWindow) {
/// <summary>Opens a Telerik Window after ensuring the window is refreshed back to its original URL and resized to its contents.</summary>
/// <param name="tWindow" type="kendoWindow">The Telerik Window to open.</param>
// Does the window have an iframe?
if
(tWindow.options.iframe) {
// Yes
// Get iframe document
var
iframe = tWindow.element.children(
"iframe"
)[0];
// Get iframe's original and current urls
var
originalURL = iframe.src;
var
currentURL = iframe.contentDocument.location.href;
// Do the urls match?
if
(originalURL !== currentURL) {
// No, refresh window back to original url
tWindow.refresh();
}
else
{
// Yes, ensure window is sized to contents
this
.ResizeWindow(tWindow);
}
}
// Open window
tWindow.open();
},
ResizeWindow:
function
(tWindow, minWidth, minHeight) {
/// <summary>Resizes a Telerik Window to its contents while keeping window within screen bounds.</summary>
/// <param name="tWindow" type="kendoWindow">The Telerik Window to resize.</param>
/// <param name="minWidth" type="int">The desired min width of window (defaults to 800px to keep bootstrap small columns from wrapping)</param>
/// <param name="minHeight" type="int">The desired min height of window (defaults to 375px to keep intial IE load from being too short)</param>
// Ensure minWidth and minHeight are defined
minWidth = (
typeof
minWidth ===
"undefined"
? 800 : minWidth);
minHeight = (
typeof
minHeight ===
"undefined"
? 375 : minHeight);
var
oldWidth = tWindow.options.width;
var
oldHeight = tWindow.options.height;
var
newWidth = oldWidth;
var
newHeight = oldHeight;
// Does the window have an iframe?
if
(tWindow.options.iframe) {
// Yes
// Get iframe content size (adding 40px height buffer)
var
$iframeBody = tWindow.element.children(
"iframe"
).contents().find(
"body"
);
var
iframeWidth = $iframeBody.width();
var
iframeHeight = $iframeBody.height() + 40;
// Initialize set new width and height to iframe dimensions
newWidth = (iframeWidth > minWidth ? iframeWidth : minWidth);
newHeight = (iframeHeight < minHeight ? minHeight : iframeHeight);
}
// Ensure window fits within screen bounds (using 50px buffer)
var
browserWindowWidth = window.innerWidth - 50;
var
browserWindowHeight = window.innerHeight - 50;
newWidth = (newWidth >= browserWindowWidth ? browserWindowWidth : newWidth);
newHeight = (newHeight >= browserWindowHeight ? browserWindowHeight : newHeight);
// Resize window, if needed
if
(newWidth !== oldWidth || newHeight !== oldHeight) {
tWindow.setOptions({ width: newWidth, height: newHeight });
}
// Ensure window is still centered
tWindow.center();
}
};