MVC Partial view with controller, ajax - how do I ge the partial controller to get data?

前端 未结 2 1343
闹比i
闹比i 2021-01-25 11:45

I\'m learning MVC and am stumped by this. I\'m trying to factor some common code that gets data and displays it in a WebGrid into a partial view that i can use on multiple pages

2条回答
  •  猫巷女王i
    2021-01-25 12:20

    The partial page won't pass through a controller, but simply render the view directly. If you want to pass view data to the partial view, there is an overloaded function that takes a viewdata dictionary. I'm sorry I can't be more detailed, but I'm on my mobile (waiting for my son to fall asleep in the other room) :)

    Update:

    If you want to trigger a GET action for your partial view, you can use Html.Action. Here are some useful links:

    • MSDN RenderAction
    • Difference between RenderPartial and RenderAction

    Further, it would probably make sense for you to move your form tags into your partial view, but those are details for when you clean up the code.

提交回复
热议问题