0

This is my simple image on which i want to pass id on image click:

<img class="pull-right" src="~/assest/image/cross.png" data-bind="attr: { href: unfollowAction }" alt="" />

but it is not hitting the controller action method. i am implementing knockout.js here to send id to unfollow action method like this:

self.unfollowAction = location.protocol + "//" + location.host + '/Post/Unfollow?uid=' + data.PostId;

Please tell me the exact correct syntax for data-bind in img tag helper.many many thnks in advance.

2 Answers2

0

You need a Html Action Image

@Html.ActionImage("unfollowAction", new { id = MyId }, "~/Content/Images/Image.bmp", "Edit")

See this answer for more details

Community
  • 1
  • 1
rory
  • 1,490
  • 3
  • 22
  • 50
0

Well, you should try something like this:

   <a data-bind="attr:{ href: unfollowAction }">
      <img class="pull-right" src="~/assest/images/cross.png" alt="" />
    </a>
duke
  • 1,816
  • 2
  • 18
  • 32