@URL.Action on ancher click and dynamic dropdown bind.

Controler Code:

ViewBag.StatusMaster = new SelectList(StatusMaster, “ID”, “TaskStatus”);

 

View Page code:

@SelectedSchoolName Unmapped projects
— @if (SelectedSchoolID > 0)
— {

    — @{int counter = 0;}
    — @foreach (var item in UnmappedProjectList)
    — {
    — counter=item.ID;

  1. @item.ProjectName
    —-
    — @Html.DropDownList(string.Format(“StatusMaster_{0}”, counter), ViewBag.StatusMaster as SelectList, “Select Status”, new { @class = “form-control” })
    Map

  2. — }

— }

Script Code:

https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js

$(“.ProjectMapAncher”).click(function (evt) {
var suffixControl_id = $(this).attr(‘data-id’);
var fakedUri = $(“#ProjectMapAncher_” + suffixControl_id).prop(“href”);
var Remarksvalue = $(“#Remarks_” + suffixControl_id).val();
var TaskStatusValue = $(‘#StatusMaster_’ + suffixControl_id).val();
if (TaskStatusValue == “”) {
$(“#dialog-text_” + suffixControl_id).html(“Select Status”);
return false;
}
else {
var uri = fakedUri.replace(“EnterRemarksValueHere”, Remarksvalue).replace(“EnterTaskStatusValueHere”, TaskStatusValue);
$(this).attr(“href”, uri);
}

});

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s