开发者

ASP.NET MVC areas with anchor tag

开发者 https://www.devze.com 2023-01-29 09:41 出处:网络
How can i call a javascript funciton on the click of an anchor tag? I am using areas as well. I need to get the views from开发者_StackOverflow社区 areas on the click of an anchor tag.

How can i call a javascript funciton on the click of an anchor tag? I am using areas as well. I need to get the views from开发者_StackOverflow社区 areas on the click of an anchor tag.

List

this getlist() makes an ajax call and get the view back. I dont want the page to be refreshed. hence i am making an ajax call.

Now i am confused how to invoke area.

if i am using an Action Link, I can use like this.

<%=Html.ActionLink("List","GetList",new {area="Blog"},null) %>

but i am using anchor tag, how can i do this???

Please let me know if i am confusing.


You could use jquery to attach a .click() event handler to this anchor tag:

$(function() {
    $('a').click(function() {
        // When an anchor is clicked
        // Use the clicked anchor href to send an AJAX call
        // and update a div with id="resultDiv" with the contents
        // sent by the server
        $('#resultDiv').load(this.href);
        // cancel the default action which is to redirect
        return false;
    });
});
0

精彩评论

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

关注公众号