Html.ActionLink in a button
Posted
by
Pomster
on Stack Overflow
See other posts from Stack Overflow
or by Pomster
Published on 2012-05-31T10:06:35Z
Indexed on
2012/05/31
10:41 UTC
Read the original article
Hit count: 162
I Am trying to connect to a method in my controller, with a button. I can connect though this link:
@Html.ActionLink("Print", "Print", new { id = Model.SalesContractId})
But i Don't want a link, i want my button on my dialog to do it. I have tried the following:
$('#btnDialogPrint').click(function () {
location.href = '<%= Url.Action("Print", "Print", new { id = Model.SalesContractId}) %>';
});
But it just redirect me to a page that say bad request.
namespace Contract.Controllers
{
public class ContractController : Controller
{
CompassEntities db = new CompassEntities();
public ActionResult Print(int id)
{
return View(""); // This can be removed and Print code may be added
}
Don't worry about the code inside i will get to that once i get inside this method.
Could i maybe attach a link here?
<input type="button" value="Print" id="btnDialogPrint" />
© Stack Overflow or respective owner