@model string
@{
ViewBag.Title = "Jquery template tag inside Url.Action";
}
<
h2
>
Jquery template tag inside Url.Action</
h2
>
@if (false)
{
<
script
type
=
"text/javascript"
src
=
"../../Scripts/jquery-1.6.2-vsdoc.js"
></
script
>
}
<
script
src
=
"@Url.Content("
~/Scripts/jquery.unobtrusive-ajax.js")"
type
=
"text/javascript"
></
script
>
<
script
type
=
"text/javascript"
src
=
"@Url.Content("
~/Content/MVC3TestApp2/Scripts/jquery.tmpl.js")"></
script
>
<
script
id
=
"memberDetailTemplate"
type
=
"text/x-jquery-tmpl"
>
<
tr
>
<
td
>
${EmployeeName}
</
td
>
<
td
>
${Experience}
</
td
>
<
td
>
{{if Designation == 'Tech Lead'}}
<
span
style
=
"color:Green; font-weight: bold;"
>${Designation}</
span
>
{{else}}
<
span
style
=
"color:Blue;"
>${Designation}</
span
>
{{/if}}
</
td
>
<
td
style
=
"text-align:center;"
>
<
a
href
=
"@HttpUtility.UrlDecode(Url.Action("
MemberDetails", "ProjectMemberDetails", new {
id
=
"${EmployeeId}"
}))">View</
a
>
</
td
>
</
tr
>
</
script
>
<
script
type
=
"text/javascript"
>
$(document).ready(function () {
$.ajax({ type: "POST", url: '@Url.Action("ProjectMemberListForTemplateCheckJson", "ProjectMemberDetails")', success: jsonProjectMemberListSuccessCallback });
});
function jsonProjectMemberListSuccessCallback(data) {
var targetElement = $('#memberData');
targetElement.empty();
$("#memberDetailTemplate").tmpl(data).appendTo('#memberData');
}
</
script
>
<
div
id
=
"loadingFeedback"
style
=
"display: none; color: Red; font-weight: bold;"
>
<
p
>
Loading details....
</
p
>
</
div
>
@using (Ajax.BeginForm(new AjaxOptions
{
LoadingElementId = "loadingFeedback",
OnSuccess = "jsonProjectMemberListSuccessCallback",
Url = Url.Action("ProjectMemberListForTemplateCheckJson", "ProjectMemberDetails")
}))
{
<
table
border
=
"1"
cellpadding
=
"0"
cellspacing
=
"0"
>
<
thead
>
<
tr
>
<
th
>
Member Name
</
th
>
<
th
>
Experience
</
th
>
<
th
>
Designation
</
th
>
<
th
>
View Details
</
th
>
</
tr
>
</
thead
>
<
tbody
id
=
"memberData"
>
</
tbody
>
</
table
>
<
p
>
@Html.Label("", "Member with experience greater than : ")
@Html.DropDownList("experience", new SelectList(new[] { "All", "1", "2", "3", "4", "5", "6", "7", "8", "9" }, (Model ?? "All")))
<
input
type
=
"submit"
name
=
"Submit"
value
=
"Submit"
/>
</
p
>
}