i have a partial view in my website, shared among many pages, for searching functionality, consisting of:
from date
to date
file type
file name
now,the problem is, in some pages i dont want the file type to be included, in other pages i dont want the (from-to) date criteria to be included
what should i do? should i create a partial view for each functionality? or show/hide the criteria from within?
_Filters.cshtml
@model Entities.FilterOperations
<table width="85%" border="0" align="center" cellpadding="0" cellspacing="1">
<tr>
<td class="formtit">
Start Date
</td>
</tr>
<tr>
<td>@Html.TextBoxFor(m => m.StartDate, new { @class = "date" })
</td>
</tr>
<tr>
<td class="formtit">
End Date
</td>
</tr>
<tr>
<td>@Html.TextBoxFor(m => m.EndDate, new { @class = "date" })
</td>
</tr>
<tr>
<td class="formtit">
File Type
</td>
</tr>
<tr>
<td>@Html.TextBoxFor(m => m.FileType)
</td>
</tr>
<tr>
<td class="formtit">
File Name
</td>
</tr>
<tr>
<td>@Html.TextBoxFor(m => m.FileName)
</td>
</tr> <tr>
<td align="right">
<input type="submit" value="Search" />
</td>
</tr>
</table>
Just add a few properties to your FilterOperations model like:
With a new ctor:
Now you can set conditions in your partial like so:
Then in your view call your partial like so: