I have a overview page which contains a table. In each td I display a name, picture, and a price. What I like is that when I click on the cell an actionlink is fired to display the details page.
Thanks for the reply. I have it almost working. When I don't have the guid furnitureid as a parameter in the Furnituredetails method it works. Is there a possibility to do something like:
var navigaturl = '@url.Action("FurnitureDetails", "Furniture", new {furnitureid=id})'
sverheggen
Member
29 Points
22 Posts
ActionLink on total TD
Feb 20, 2012 07:20 PM|LINK
Hi All,
I have a overview page which contains a table. In each td I display a name, picture, and a price. What I like is that when I click on the cell an actionlink is fired to display the details page.
Does anyone know how I can achieve this?
Thanks for the help.
Regards,
Stefan
ignatandrei
All-Star
134947 Points
21626 Posts
Moderator
MVP
Re: ActionLink on total TD
Feb 20, 2012 08:00 PM|LINK
td onclick
sverheggen
Member
29 Points
22 Posts
Re: ActionLink on total TD
Feb 21, 2012 08:52 AM|LINK
Thanks for the quick reply. And how can I code in the onclick that it calls the controller actionmethod?
Thanks for your help already.
Regards,
Stefan
ignatandrei
All-Star
134947 Points
21626 Posts
Moderator
MVP
Re: ActionLink on total TD
Feb 21, 2012 09:19 AM|LINK
http://bit.ly/mvc_ajax_jquery
sverheggen
Member
29 Points
22 Posts
Re: ActionLink on total TD
Feb 21, 2012 07:05 PM|LINK
Hi all,
I think I have it almost working, because I get back the page in an alert.
<script type="text/javascript"> function navigate(id) { var navigateurl = '@Url.Action("FurnitureDetails", "Furniture")'; alert(id); $.post(navigateurl, { furnitureId: id });// $.ajax({ url: navigateurl, type: "GET", data: JSON.stringify(id), datatype: "JSON", contentType: "application/json; charset=utf-8" }); }</script>ignatandrei
All-Star
134947 Points
21626 Posts
Moderator
MVP
Re: ActionLink on total TD
Feb 21, 2012 07:56 PM|LINK
window.location = ...
sverheggen
Member
29 Points
22 Posts
Re: ActionLink on total TD
Feb 23, 2012 08:22 PM|LINK
Thanks for the reply. I have it almost working. When I don't have the guid furnitureid as a parameter in the Furnituredetails method it works. Is there a possibility to do something like:
var navigaturl = '@url.Action("FurnitureDetails", "Furniture", new {furnitureid=id})'
window.location = navigaturl;
Thanks for your help already.
Stefan
ignatandrei
All-Star
134947 Points
21626 Posts
Moderator
MVP
Re: ActionLink on total TD
Feb 24, 2012 03:36 AM|LINK
The code is valid.
sverheggen
Member
29 Points
22 Posts
Re: ActionLink on total TD
Feb 24, 2012 07:46 PM|LINK
Hi Andrei,
If I use this code I get an error cs103 the variable id does not exist in the context.
function navigate(id) { var navigateurl = '@Url.Action("FurnitureDetails", "Furniture", new {furnitureId=id})';sverheggen
Member
29 Points
22 Posts
Re: ActionLink on total TD
Feb 24, 2012 08:03 PM|LINK
Hi All,
I don't understand why it isn't working with the above code. I solved it in another way.
This is the code:
<script type="text/javascript"> function navigate(id) { var navigateurl = '@Url.Action("FurnitureDetails", "Furniture")'; var data = { "furnitureId": id }; navigateurl = navigateurl + '?' + $.param(data); window.location = navigateurl; } </script>I also like to know how I can get it working with the above code. So if anyone has an idea.
I want to thank especially Andrei for the help.
Regards,
Stefan