{"id":411,"date":"2013-08-16T16:54:45","date_gmt":"2013-08-16T20:54:45","guid":{"rendered":"http:\/\/binaryworld.net\/blogs\/?p=411"},"modified":"2013-09-18T07:21:37","modified_gmt":"2013-09-18T11:21:37","slug":"how-to-provide-custom-button-for-search-in-lightswitch","status":"publish","type":"post","link":"https:\/\/binaryworld.net\/blogs\/how-to-provide-custom-button-for-search-in-lightswitch\/","title":{"rendered":"How to provide custom button for search in LightSwitch"},"content":{"rendered":"<p>Recently someone asked me how to change default LightSwitch behavior for Search screen. Which is press enter for search. But what if you want to provide Button which user can Press to search data? Here is step-by-step info on how to do that.<\/p>\n<p>1. First thing we need to do is disable Auto Refresh of query so when you type in search parameter fields\u00a0it doesn&#8217;t auto refresh data (This usually happens when Focus of textbox is changed).<\/p>\n<blockquote><p>This has obvious side effect &#8230; Changing Page doesnt refresh grid. So if you really find this unacceptable then skip this step and leave  auto-refresh checked<\/p><\/blockquote>\n<p><a href=\"http:\/\/binaryworld.net\/blogs\/wp-content\/uploads\/2013\/08\/lightswitch-disable-auto-refresh.jpg\"><img loading=\"lazy\" decoding=\"async\" title=\"lightswitch-disable-auto-refresh\" src=\"http:\/\/binaryworld.net\/blogs\/wp-content\/uploads\/2013\/08\/lightswitch-disable-auto-refresh.jpg\" alt=\"\" width=\"585\" height=\"369\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>2. Next add new custom button<\/p>\n<p><a href=\"http:\/\/binaryworld.net\/blogs\/wp-content\/uploads\/2013\/08\/lightswitch-add-custom-button.png\"><img loading=\"lazy\" decoding=\"async\" title=\"lightswitch-add-custom-button\" src=\"http:\/\/binaryworld.net\/blogs\/wp-content\/uploads\/2013\/08\/lightswitch-add-custom-button.png\" alt=\"\" width=\"424\" height=\"246\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>3. When prompted name button click method name and click OK.<\/p>\n<p><a href=\"http:\/\/binaryworld.net\/blogs\/wp-content\/uploads\/2013\/08\/LightSwitch-Create-Method.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-414\" title=\"LightSwitch-Create-Method\" src=\"http:\/\/binaryworld.net\/blogs\/wp-content\/uploads\/2013\/08\/LightSwitch-Create-Method.jpg\" alt=\"\" width=\"416\" height=\"221\" srcset=\"https:\/\/binaryworld.net\/blogs\/wp-content\/uploads\/2013\/08\/LightSwitch-Create-Method.jpg 416w, https:\/\/binaryworld.net\/blogs\/wp-content\/uploads\/2013\/08\/LightSwitch-Create-Method-300x159.jpg 300w\" sizes=\"(max-width: 416px) 100vw, 416px\" \/><\/a><\/p>\n<p>4. Now you should see new button in the layout tree. Highlight it and go to properties window to change its default Caption<\/p>\n<p>5.\u00a0By default button will be added to default commandbar in layout tree But you might want to re-arrange so it appears after Search parameters. Once re-arrange is done right click on new button and click on Edit Execute Code as below<\/p>\n<p><a href=\"http:\/\/binaryworld.net\/blogs\/wp-content\/uploads\/2013\/08\/lightswitch-add-execute-code.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-415\" title=\"lightswitch-add-execute-code\" src=\"http:\/\/binaryworld.net\/blogs\/wp-content\/uploads\/2013\/08\/lightswitch-add-execute-code.png\" alt=\"\" width=\"340\" height=\"195\" srcset=\"https:\/\/binaryworld.net\/blogs\/wp-content\/uploads\/2013\/08\/lightswitch-add-execute-code.png 340w, https:\/\/binaryworld.net\/blogs\/wp-content\/uploads\/2013\/08\/lightswitch-add-execute-code-300x172.png 300w\" sizes=\"(max-width: 340px) 100vw, 340px\" \/><\/a><\/p>\n<p>6. And the type below code in code window&#8230;. That&#8217;s it .. Now user can click on your own custom button to invoke search.<\/p>\n<pre class=\"brush: vbnet; gutter: true; first-line: 1; highlight: []; html-script: false\">\r\nNamespace LightSwitchApplication\r\n    Public Class SearchOrdersSearchQuery\r\n\r\n        Private Sub SearchClick_Execute()\r\n            OrdersSearchQuery.Refresh()\r\n        End Sub\r\n\r\n    End Class\r\nEnd Namespace\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Recently someone asked me how to change default LightSwitch behavior for Search screen. Which is press enter for search. But what if you want to provide Button which user can Press to search data? Here is step-by-step info on how &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"https:\/\/binaryworld.net\/blogs\/how-to-provide-custom-button-for-search-in-lightswitch\/\"> <span class=\"screen-reader-text\">How to provide custom button for search in LightSwitch<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":417,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[49,76,65],"tags":[162,50],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\r\n<title>How to provide custom button for search in LightSwitch - BinaryWorld Blog<\/title>\r\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\r\n<link rel=\"canonical\" href=\"https:\/\/binaryworld.net\/blogs\/how-to-provide-custom-button-for-search-in-lightswitch\/\" \/>\r\n<meta property=\"og:locale\" content=\"en_US\" \/>\r\n<meta property=\"og:type\" content=\"article\" \/>\r\n<meta property=\"og:title\" content=\"How to provide custom button for search in LightSwitch - BinaryWorld Blog\" \/>\r\n<meta property=\"og:description\" content=\"Recently someone asked me how to change default LightSwitch behavior for Search screen. Which is press enter for search. But what if you want to provide Button which user can Press to search data? Here is step-by-step info on how &hellip; How to provide custom button for search in LightSwitch Read More &raquo;\" \/>\r\n<meta property=\"og:url\" content=\"https:\/\/binaryworld.net\/blogs\/how-to-provide-custom-button-for-search-in-lightswitch\/\" \/>\r\n<meta property=\"og:site_name\" content=\"BinaryWorld Blog\" \/>\r\n<meta property=\"article:published_time\" content=\"2013-08-16T20:54:45+00:00\" \/>\r\n<meta property=\"article:modified_time\" content=\"2013-09-18T11:21:37+00:00\" \/>\r\n<meta property=\"og:image\" content=\"https:\/\/binaryworld.net\/blogs\/wp-content\/uploads\/2013\/08\/lightswitch-disable-auto-refresh1.jpg\" \/>\r\n\t<meta property=\"og:image:width\" content=\"585\" \/>\r\n\t<meta property=\"og:image:height\" content=\"369\" \/>\r\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\r\n<meta name=\"author\" content=\"Binary World\" \/>\r\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\r\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Binary World\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\r\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/binaryworld.net\/blogs\/how-to-provide-custom-button-for-search-in-lightswitch\/\",\"url\":\"https:\/\/binaryworld.net\/blogs\/how-to-provide-custom-button-for-search-in-lightswitch\/\",\"name\":\"How to provide custom button for search in LightSwitch - BinaryWorld Blog\",\"isPartOf\":{\"@id\":\"https:\/\/binaryworld.net\/blogs\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/binaryworld.net\/blogs\/how-to-provide-custom-button-for-search-in-lightswitch\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/binaryworld.net\/blogs\/how-to-provide-custom-button-for-search-in-lightswitch\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/binaryworld.net\/blogs\/wp-content\/uploads\/2013\/08\/lightswitch-disable-auto-refresh1.jpg\",\"datePublished\":\"2013-08-16T20:54:45+00:00\",\"dateModified\":\"2013-09-18T11:21:37+00:00\",\"author\":{\"@id\":\"https:\/\/binaryworld.net\/blogs\/#\/schema\/person\/77cf0a9a512dd22bff93c6a1b6374fe0\"},\"breadcrumb\":{\"@id\":\"https:\/\/binaryworld.net\/blogs\/how-to-provide-custom-button-for-search-in-lightswitch\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/binaryworld.net\/blogs\/how-to-provide-custom-button-for-search-in-lightswitch\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/binaryworld.net\/blogs\/how-to-provide-custom-button-for-search-in-lightswitch\/#primaryimage\",\"url\":\"https:\/\/binaryworld.net\/blogs\/wp-content\/uploads\/2013\/08\/lightswitch-disable-auto-refresh1.jpg\",\"contentUrl\":\"https:\/\/binaryworld.net\/blogs\/wp-content\/uploads\/2013\/08\/lightswitch-disable-auto-refresh1.jpg\",\"width\":\"585\",\"height\":\"369\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/binaryworld.net\/blogs\/how-to-provide-custom-button-for-search-in-lightswitch\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/binaryworld.net\/blogs\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to provide custom button for search in LightSwitch\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/binaryworld.net\/blogs\/#website\",\"url\":\"https:\/\/binaryworld.net\/blogs\/\",\"name\":\"BinaryWorld Blog\",\"description\":\"Tips and Tutorials for Microsoft SQL Server, SSIS, SSAS, Business Intelligence, C#, .net\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/binaryworld.net\/blogs\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/binaryworld.net\/blogs\/#\/schema\/person\/77cf0a9a512dd22bff93c6a1b6374fe0\",\"name\":\"Binary World\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/binaryworld.net\/blogs\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/eaea47799daa577835eb53e64dfd3e13?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/eaea47799daa577835eb53e64dfd3e13?s=96&d=mm&r=g\",\"caption\":\"Binary World\"},\"description\":\"Binary World is a Software Development company located in Atlanta, USA (since 2007). Binary World specialized in Business Intelligence, mobile, cloud computing and .Net Application Development.\",\"url\":\"https:\/\/binaryworld.net\/blogs\/author\/admin\/\"}]}<\/script>\r\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to provide custom button for search in LightSwitch - BinaryWorld Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/binaryworld.net\/blogs\/how-to-provide-custom-button-for-search-in-lightswitch\/","og_locale":"en_US","og_type":"article","og_title":"How to provide custom button for search in LightSwitch - BinaryWorld Blog","og_description":"Recently someone asked me how to change default LightSwitch behavior for Search screen. Which is press enter for search. But what if you want to provide Button which user can Press to search data? Here is step-by-step info on how &hellip; How to provide custom button for search in LightSwitch Read More &raquo;","og_url":"https:\/\/binaryworld.net\/blogs\/how-to-provide-custom-button-for-search-in-lightswitch\/","og_site_name":"BinaryWorld Blog","article_published_time":"2013-08-16T20:54:45+00:00","article_modified_time":"2013-09-18T11:21:37+00:00","og_image":[{"width":"585","height":"369","url":"https:\/\/binaryworld.net\/blogs\/wp-content\/uploads\/2013\/08\/lightswitch-disable-auto-refresh1.jpg","type":"image\/jpeg"}],"author":"Binary World","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Binary World","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/binaryworld.net\/blogs\/how-to-provide-custom-button-for-search-in-lightswitch\/","url":"https:\/\/binaryworld.net\/blogs\/how-to-provide-custom-button-for-search-in-lightswitch\/","name":"How to provide custom button for search in LightSwitch - BinaryWorld Blog","isPartOf":{"@id":"https:\/\/binaryworld.net\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/binaryworld.net\/blogs\/how-to-provide-custom-button-for-search-in-lightswitch\/#primaryimage"},"image":{"@id":"https:\/\/binaryworld.net\/blogs\/how-to-provide-custom-button-for-search-in-lightswitch\/#primaryimage"},"thumbnailUrl":"https:\/\/binaryworld.net\/blogs\/wp-content\/uploads\/2013\/08\/lightswitch-disable-auto-refresh1.jpg","datePublished":"2013-08-16T20:54:45+00:00","dateModified":"2013-09-18T11:21:37+00:00","author":{"@id":"https:\/\/binaryworld.net\/blogs\/#\/schema\/person\/77cf0a9a512dd22bff93c6a1b6374fe0"},"breadcrumb":{"@id":"https:\/\/binaryworld.net\/blogs\/how-to-provide-custom-button-for-search-in-lightswitch\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/binaryworld.net\/blogs\/how-to-provide-custom-button-for-search-in-lightswitch\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/binaryworld.net\/blogs\/how-to-provide-custom-button-for-search-in-lightswitch\/#primaryimage","url":"https:\/\/binaryworld.net\/blogs\/wp-content\/uploads\/2013\/08\/lightswitch-disable-auto-refresh1.jpg","contentUrl":"https:\/\/binaryworld.net\/blogs\/wp-content\/uploads\/2013\/08\/lightswitch-disable-auto-refresh1.jpg","width":"585","height":"369"},{"@type":"BreadcrumbList","@id":"https:\/\/binaryworld.net\/blogs\/how-to-provide-custom-button-for-search-in-lightswitch\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/binaryworld.net\/blogs\/"},{"@type":"ListItem","position":2,"name":"How to provide custom button for search in LightSwitch"}]},{"@type":"WebSite","@id":"https:\/\/binaryworld.net\/blogs\/#website","url":"https:\/\/binaryworld.net\/blogs\/","name":"BinaryWorld Blog","description":"Tips and Tutorials for Microsoft SQL Server, SSIS, SSAS, Business Intelligence, C#, .net","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/binaryworld.net\/blogs\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/binaryworld.net\/blogs\/#\/schema\/person\/77cf0a9a512dd22bff93c6a1b6374fe0","name":"Binary World","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/binaryworld.net\/blogs\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/eaea47799daa577835eb53e64dfd3e13?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/eaea47799daa577835eb53e64dfd3e13?s=96&d=mm&r=g","caption":"Binary World"},"description":"Binary World is a Software Development company located in Atlanta, USA (since 2007). Binary World specialized in Business Intelligence, mobile, cloud computing and .Net Application Development.","url":"https:\/\/binaryworld.net\/blogs\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/binaryworld.net\/blogs\/wp-json\/wp\/v2\/posts\/411"}],"collection":[{"href":"https:\/\/binaryworld.net\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/binaryworld.net\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/binaryworld.net\/blogs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/binaryworld.net\/blogs\/wp-json\/wp\/v2\/comments?post=411"}],"version-history":[{"count":0,"href":"https:\/\/binaryworld.net\/blogs\/wp-json\/wp\/v2\/posts\/411\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/binaryworld.net\/blogs\/wp-json\/wp\/v2\/media\/417"}],"wp:attachment":[{"href":"https:\/\/binaryworld.net\/blogs\/wp-json\/wp\/v2\/media?parent=411"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/binaryworld.net\/blogs\/wp-json\/wp\/v2\/categories?post=411"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/binaryworld.net\/blogs\/wp-json\/wp\/v2\/tags?post=411"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}