Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using mvc3 application

i have 3 div
like

HTML
@model demomodel
<div>Name: <input type="text" value=|"@Model.Name"></div>
<div>Address: <input type="text" value=|"@Model.Address">
<br/>
<input type="Button" value="Search">
</div>
<Div id="searchdiv">

<table>
<tr>
<td>Name</td>
<td>Address</td>
</tr>

@foreach(var item in Model.seachlist)
{
<trr>
<td>@item.Name</td>
<td>@item.Address</td>
</trr>
}
</table>
</div>

how can i refresh only searchdiv instead of refresh the page on click of search button just result will come in to searchdiv
Posted
Updated 25-Aug-14 22:27pm
v2

1 solution

First of all you need to use one partial view.. for searching if you want to refresh only the Search div.
write below code in the partial view and use the same model its your wish you can make another
<div id="searchdiv">
 
<table>
<tr>
<td>Name</td>
<td>Address</td>
</tr>
 
@foreach(var item in Model.seachlist)
{
<tr>
<td>@item.Name</td>
<td>@item.Address</td>

}
</tr></table>
</div>


If you don't want to do this way then by using jQuery you need to generate the table html code with the header and your populated json resulte provided value.

How about a code sample :)
C#
var table = $('<table></table>').addClass('foo');
for(i=0; i<3; i++){
    var row = $('<tr></tr>').addClass('bar').text('result ' + i);
    table.append(row);
}

$('#here_table').append(table);


in place of for loop you can use foreach json result.

[try this link for examples]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900