I'm Fresher & trying to create a simple crud method on same page with using jquery hide and show methods. Its working well on a single button, but on edit button, my hidden form does showing through jq ('show') method. Please help me I'm very confused.
here is my form:
<div id="form">
@using (Html.BeginForm("Add", "Final", FormMethod.Post))
{
<div class="form-horizontal">
@Html.HiddenFor(model => model.ID)
<div class="form-group">
@Html.EditorFor(model => model.Name, new { htmlAttributes = new { @class = "form-control", @placeholder = "Name" } })
</div>
<div class="form-group">
@Html.EditorFor(model => model.Password, new { htmlAttributes = new { @class = "form-control", @placeholder = "Password" } })
</div>
<div class="form-group">
<input type="submit" value="AddEdit" class="btn btn-default" />
</div>
</div>
}
</div>
here is my Grid View
<div style="margin:2% 0 0 0%" id="Grid">
@{
var getList = ViewBag.list as IEnumerable<login.Models.Employee>;
<table class="table table-striped">
<tr style="background-color:#247bf5; color:white">
<th> Emp No. </th>
<th> Name </th>
<th> Password </th>
<th> Email </th>
<th> Adress </th>
<th> Deparmtnet </th>
<th> Udate </th>
<th> Delete </th>
</tr>
<tbody>
@foreach (var item in getList)
{
<tr>
<td> @(a++) </td>
<td>@item.Name</td>
<td>@item.Password</td>
<td>@item.Email</td>
<td>@item.Adresss</td>
<td>@item.Department</td>
<td>
<div class="btn btn-primary" id="show">
@*@Html.ActionLink("Add", "Edit", new { id = @item.ID }, new { @class = "text", data_toggle = "modal", data_target = "#myModal" })<br />*@
@Html.ActionLink("Edit", "Index", new { id = @item.ID }, new { @class = "text" })
</div>
</td>
<td>
<div class="btn btn-danger">
@Html.ActionLink("Del", "Delete", new { id = @item.ID }, new { @class = "text" })
</div>
</td>
</tr>
}
</tbody>
</table>
}
</div>
here is edit new recrod button:
@Html.ActionLink("Edit", "Index", new { id = @item.ID }, new { @class = "text" })
here is my jq code
<script>
$(document).ready(function () {
$("#form").hide();
$("#addbtn").click(function () {
$("#form").show();
});
$(".text").click(function () {
debugger
$("#form").show();
});
});
</script>