UPDATE:
In my investigation, I discovered that a plain input tag without MVC RAZOR works as expected:
<input type="text" class="hiddenid2" /> //WORKED
However, when using the following code, it does not work:
@Html.Editor("id", "", new { htmlAttributes = new { @class = "hiddenId2" } })
or
@Html.Editor("id", "", new { @class = "hiddenId2" })
The issue is perplexing me after meticulously reviewing each line of code. Everything seems correct, but I'm unsure of what else needs to be done in this situation.
The problem I am encountering is:
I need to pass the Id to two modal popups with different Ids and class names. The first modal popup successfully passes the Id, but the second one does not.
First Modal:
//View Link
<a href="/Home/Employee/@item.Id" data-id="@item.Id"
data-toggle="modal" data-target="#myModal"
class="modalLink">Load Employee</a>
View:
@using (Html.BeginForm("Employee", "Home", FormMethod.Post))
{
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">Record</h4>
</div>
<div class="modal-body">
@Html.Hidden("id", "", new { @class = "hiddenid" })
</div>
<div class="modal-footer">
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
}
JQuery:
$(.modalLink").click(function () {
var passedID = $(this).data('id');
$('#id').val(passedID);
$(".modal-body .hiddenid").val(passedID);
});
Second Modal:
//View Link
<a href="/Home/Employer/@item.Id" data-id="@item.Id"
data-toggle="modal" data-target="#myModal2"
class="modalLink2">Load Employer</a>
View:
@using (Html.BeginForm("Employer", "Home", FormMethod.Post))
{
<div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">Record</h4>
</div>
<div class="modal-body">
@Html.Hidden("id", "", new { @class = "hiddenid" })
</div>
<div class="modal-footer">
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
}
JQuery:
$(.modalLink2").click(function () {
var passedID = $(this).data('id');
$('#id').val(passedID);
$(".modal-body .hiddenid").val(passedID);
});