0

I've got a strongly typed partial view that shows rows from a table. I've got another strongly typed partial view that, based on what row is clicked in the first view, displays derived foreign key info. I want this data to show without reloading the whole page. I'll have to query a database in my controller to do this.
I've heard of divs being reloaded, but not strongly typed partial views. Should I use jquery or ajax? Is there any way I can avoid using either?
I've already got bundling set up.

Here's the action I've already got that reloads the whole page

<tr onclick="location.href = '@(Url.Action("ReloadPartialDetails", "MyClassController", new { ID = item.ID }))'">
tereško
  • 58,060
  • 25
  • 98
  • 150
Jooooosh
  • 331
  • 2
  • 4
  • 13
  • You can render the markup ( html controls ) using ajax jquery but in order to bind the model data to the razor expression, you need to do a fullpost back to ActionResult method. If your requirement has 2 different models, then you would need to implement partial views. – DinoMyte Sep 29 '14 at 19:37
  • I'm probably misunderstanding what you mean by model binding, but I only need to display the info I'm getting. It'll never be posted. Would I still need to do a full post in this case? The response I'm trying to fill my div with is a partial view. – Jooooosh Sep 29 '14 at 20:10
  • Correct. The razor expression only gets rendered during fullpostback. – DinoMyte Sep 29 '14 at 21:30
  • Alright thanks. It's not much data being shown so I could just make it a string or html, so there's one solution. I take it ajax forms will work but not for razor? Is there any way I could force my razor view to render and just return a string? Thanks for your help. – Jooooosh Sep 30 '14 at 13:08
  • Oh man looks like you can. http://stackoverflow.com/questions/9243433/how-to-render-a-razor-view-to-a-string-in-asp-net-mvc-3 – Jooooosh Sep 30 '14 at 13:23
  • The last thing I'm having trouble with is finding out what row was clicked. I'll have to try and find that out. – Jooooosh Sep 30 '14 at 13:42

0 Answers0