{"id":113,"date":"2014-05-02T21:12:00","date_gmt":"2014-05-02T20:12:00","guid":{"rendered":"https:\/\/debuggersspace.com\/index.php\/2014\/05\/02\/search-box-in-mvc\/"},"modified":"2014-05-02T21:12:00","modified_gmt":"2014-05-02T20:12:00","slug":"search-box-in-mvc","status":"publish","type":"post","link":"https:\/\/debuggersspace.com\/index.php\/2014\/05\/02\/search-box-in-mvc\/","title":{"rendered":"Search box in MVC"},"content":{"rendered":"<div class='booster-block booster-read-block'>\n                <div class=\"twp-read-time\">\n                \t<i class=\"booster-icon twp-clock\"><\/i> <span>Read Time:<\/span>48 Second                <\/div>\n\n            <\/div><div dir=\"ltr\" style=\"text-align: left;\">\nPut in Index File&#8230;<br \/>\n&lt;p&gt;<br \/>\n&nbsp; &nbsp;@using (Html.BeginForm(&#8220;Index&#8221;, &#8220;Department&#8221;, FormMethod.Get)) {<br \/>\n&nbsp; &nbsp;&lt;b&gt;Search By:&lt;\/b&gt;@Html.RadioButton(&#8220;searchBy&#8221;, &#8220;search&#8221;,true)&lt;text&gt;Name&lt;\/text&gt;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp;@Html.TextBox(&#8220;search&#8221;)&lt;input type=&#8221;submit&#8221; value=&#8221;search&#8221; \/&gt;<br \/>\n&nbsp; &nbsp;}<br \/>\n&nbsp; &nbsp; &lt;\/p&gt;<\/p>\n<p>&#8212;DepartmentController<br \/>\n&nbsp;public ActionResult Index(string searchBy, string search)<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; {<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (searchBy == &#8220;Name&#8221;)<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return View(db.Departments.Where(x =&gt; x.DprtName.StartsWith(search)).ToList());<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return View(db.Departments.Where(x =&gt; x.DprtName.StartsWith(search)).ToList());<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; }<\/p>\n<div>\n<\/div>\n<p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Put in Index File&#8230; &lt;p&gt; &nbsp; &nbsp;@using (Html.BeginForm(&#8220;Index&#8221;, &#8220;Department&#8221;, FormMethod.Get)) { &nbsp; &nbsp;&lt;b&gt;Search By:&lt;\/b&gt;@Html.RadioButton(&#8220;searchBy&#8221;, &#8220;search&#8221;,true)&lt;text&gt;Name&lt;\/text&gt; &nbsp; &nbsp; &nbsp; &nbsp;@Html.TextBox(&#8220;search&#8221;)&lt;input type=&#8221;submit&#8221; value=&#8221;search&#8221; \/&gt; &nbsp; &nbsp;} &nbsp; &nbsp; &lt;\/p&gt; &#8212;DepartmentController &nbsp;public ActionResult Index(string searchBy, string search) &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (searchBy == &#8220;Name&#8221;) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [&hellip;]<\/p>\n","protected":false},"author":43,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-113","post","type-post","status-publish","format-standard","hentry","category-blog"],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"Himanshu Namdeo","author_link":"https:\/\/debuggersspace.com\/author\/admin\/"},"uagb_comment_info":0,"uagb_excerpt":"Put in Index File&#8230; &lt;p&gt; &nbsp; &nbsp;@using (Html.BeginForm(&#8220;Index&#8221;, &#8220;Department&#8221;, FormMethod.Get)) { &nbsp; &nbsp;&lt;b&gt;Search By:&lt;\/b&gt;@Html.RadioButton(&#8220;searchBy&#8221;, &#8220;search&#8221;,true)&lt;text&gt;Name&lt;\/text&gt; &nbsp; &nbsp; &nbsp; &nbsp;@Html.TextBox(&#8220;search&#8221;)&lt;input type=&#8221;submit&#8221; value=&#8221;search&#8221; \/&gt; &nbsp; &nbsp;} &nbsp; &nbsp; &lt;\/p&gt; &#8212;DepartmentController &nbsp;public ActionResult Index(string searchBy, string search) &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (searchBy == &#8220;Name&#8221;) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&hellip;","_links":{"self":[{"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/posts\/113"}],"collection":[{"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/users\/43"}],"replies":[{"embeddable":true,"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/comments?post=113"}],"version-history":[{"count":0,"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/posts\/113\/revisions"}],"wp:attachment":[{"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/media?parent=113"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/categories?post=113"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/tags?post=113"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}