开发者

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&amp;Page=3&amp;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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜