Difference between anchor link & window.location?
I have the link below:
<a href='@Url.Action("MyAction","MyController", new SearchCriteriaAffaire { Page=3, PageSize=5 }, null)'>Test1</a>
This links works. I received my search criteria in my action page.
Now, I have the button with javascript below:
<button id="buttonTest2">Test2</button>
<script language="javascript">
$("#buttonTest2").click(function () {
document.location = '@Url.Action("MyAction","MyController", new SearchCriteriaAffaire { Page=3, PageSize=5 }, null)';
});
</script>
This button 开发者_运维百科doest' work. I mean, I didn't receive my search criteria in my action page and I don't know why??
It drives me crazy!
Test1 and Test2 produces exactly the same url (I check in 'view source code' by right clicking on the html page):
/?SortBy=None&Page=3&PageSize=5'
Any help will be greatly appreciated.
try this :
<button id="buttonTest2">Test2</button>
<script language="javascript">
$("#buttonTest2").click(function () {
document.location = '@Html.Raw(Url.Action("MyAction","MyController", new SearchCriteriaAffaire { Page=3, PageSize=5 }, null))';
});
</script>
精彩评论