Render Partial View Using jQuery in ASP.NET MVC

后端 未结 8 2075
有刺的猬
有刺的猬 2020-11-22 11:13

How do I render the partial view using jquery?

We can render the partial View like this:

<% Html.RenderPartial(\"UserDetails\"); %>
         


        
8条回答
  •  难免孤独
    2020-11-22 11:45

    Another thing you can try (based on tvanfosson's answer) is this:

    And then in the scripts section of your page:

    
    

    This renders your @Html.RenderAction using ajax.

    And to make it all fansy sjmansy you can add a fade-in effect using this css:

    /* make keyframes that tell the start state and the end state of our object */
    @-webkit-keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
    @-moz-keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
    @keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
    
    .fade-in {
        opacity: 0; /* make things invisible upon start */
        -webkit-animation: fadeIn ease-in 1; /* call our keyframe named fadeIn, use animattion ease-in and repeat it only 1 time */
        -moz-animation: fadeIn ease-in 1;
        -o-animation: fadeIn ease-in 1;
        animation: fadeIn ease-in 1;
        -webkit-animation-fill-mode: forwards; /* this makes sure that after animation is done we remain at the last keyframe value (opacity: 1)*/
        -o-animation-fill-mode: forwards;
        animation-fill-mode: forwards;
        -webkit-animation-duration: 1s;
        -moz-animation-duration: 1s;
        -o-animation-duration: 1s;
        animation-duration: 1s;
    }
    

    Man I love mvc :-)

提交回复
热议问题