TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
sangeetha k
NA
207
51.6k
How to redirect to an actionmethod which has a parameter
Apr 4 2018 3:47 AM
button is the icon link in the table:
<tbody>
@foreach (
var
item
in
Model)
{
<tr>
<td
class
=
"edit1"
scope=
"row"
>@Html.DisplayFor(model => item.Empid)</td>
<td
class
=
"edit"
>@Html.DisplayFor(model => item.Empname)</td>
<td
class
=
"edit"
>@Html.DisplayFor(model => item.Designation)</td>
@*<td>
<img src=
"@Url.Content(@item.Empimage)"
alt />
</td>*@
<td
class
=
"edit"
>
@{
var
base64 = Convert.ToBase64String(item.ImageData);
var
imagesrc = string.Format(
"data:image/jpeg;base64,{0}"
, base64);
<img src=
'@imagesrc'
style=
"max-width:100px;max-height:100px;"
/>
}
</td>
<td
class
=
"edit"
>@Html.DisplayFor(model => item.Salary)</td>
<td
class
=
"edit"
>@Html.DisplayFor(model => item.Email)</td>
<td
class
=
"edit"
>@Html.DisplayFor(model => item.Department)</td>
<td>
<a href=
"#"
data-id=
"@item.Empid"
id=
"btnDelete"
class
=
"Delete"
role=
"button"
>
<span
class
=
"glyphicon glyphicon-trash"
></span>
</a></td>
</tr>
}
</tbody>
using normal button click:
$(document).ready(
function
() {
var
empid = $(
'.Delete'
).attr(
'data-id'
);
$(
"#EmpTable"
).on(
'click'
,
'.Delete'
,(
function
() {
debugger
;
var
url =
'@Url.Action("DeleteEmployee", "Employee", new { id = empid })'
;
var
newurl = url +
"empid"
+ empid;
window.location.href = newurl;
}));
or via ajax call:
$(document).on(
'click'
,
'#btnDelete'
,
function
() {
var
empID = $(
this
).attr(
'data-id'
);
debugger
;
$.ajax(
{
type:
'GET'
,
url:
'<%=Url.Action("DeleteEmployee","Employee")%>'
,
data:
"{ EmployeeID:'"
+ empID +
"'}"
,
success:
function
(data) {
alert(
'deletion sucess'
);
}
});
both the things are not hitting tell me where i am wrong. Pls
Reply
Answers (
6
)
Quarter dropdown.
After reader read wrong value insert new row...????