{"id":2380,"date":"2011-08-12T16:08:11","date_gmt":"2011-08-12T10:38:11","guid":{"rendered":"http:\/\/JitendraZaa.com\/blog\/?p=2380"},"modified":"2011-08-12T16:08:11","modified_gmt":"2011-08-12T10:38:11","slug":"default-submit-button-in-aspx-or-master-page","status":"publish","type":"post","link":"https:\/\/www.jitendrazaa.com\/blog\/microsoft\/net\/default-submit-button-in-aspx-or-master-page\/","title":{"rendered":"Default Submit button in ASPX or Master Page"},"content":{"rendered":"<p>In ASPX page, if there is only one button one which postback is done then there is no problem. However in a case when there are lots of button in page the how you will tell aspx page that which button&#8217;s event is default?<\/p>\n<p>To solve that we have to use the &#8220;<strong>defaultButton<\/strong>&#8221; attribute of the &#8220;<strong>form<\/strong>&#8221; tag as shown in below code snap:<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n&lt;form id=&quot;form1&quot; runat=&quot;server&quot; defaultbutton = &quot;imgSearch&quot; &gt;\n....\n....\n&lt;asp:ImageButton Visible=&quot;true&quot; ID=&quot;imgSearch&quot; runat=&quot;server&quot;\/&gt;\n&lt;asp:ImageButton Visible=&quot;true&quot; ID=&quot;imgDelete&quot; runat=&quot;server&quot;\/&gt;\n&lt;\/form&gt;\n<\/pre>\n<p>In above code, the string value supplied to argument &#8220;<strong>DefaultButton<\/strong>&#8221; is the ID of the button control which should made default.<!--more--><\/p>\n<p><strong>Question : I am getting error &#8220;Defaultbutton should be the ID of a control of type\u00a0IButtonControl&#8221; in MasterPage type of application.<\/strong><br \/>\n<strong> Answer :<\/strong> If you try to implement the same logic in &#8220;ContentPlaceHolder&#8221; type of application where the form tag is at master page, it is the chance that you receive above error.<br \/>\nYou have to use the &#8220;UniqueId&#8221; property of the button control as shown in below C# code.<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\n((DefaultMaster)this.Page.Master).parentForm.DefaultButton = imgSearch.UniqueID;\n<\/pre>\n<p>In above code snap,<\/p>\n<ul>\n<li>DefaultMaster is the name of the Master Page.<\/li>\n<li>ParentForm is the public property defined on master page which returns the &#8220;HtmlForm&#8221; control of the page, so that it can be referred in child page.<\/li>\n<li>imgSearch is the imagebutton control.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>How to handle the default submit button in aspx page having contentplaceholder that is master page<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"jz_research_post":"","_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[21],"tags":[43],"class_list":["post-2380","post","type-post","status-publish","format-standard","hentry","category-net","tag-asp-net"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":132,"url":"https:\/\/www.jitendrazaa.com\/blog\/microsoft\/net\/upload-files-in-asp-net-at-production-server\/","url_meta":{"origin":2380,"position":0},"title":"Upload Files in ASP.NET at Production server","author":"Jitendra","date":"May 13, 2010","format":false,"excerpt":"In this article, i am going to demonstrate that how to upload the file in ASP.NET production server. Most of the case, a developer created a code to upload the file and test it on his local machine. program runs smoothly, but as he\u00a0forward\u00a0the same code on production. He\u00a0stuck\u00a0in the\u2026","rel":"","context":"In &quot;ASP.NET&quot;","block_context":{"text":"ASP.NET","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/microsoft\/net\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2010\/05\/WebShare-Folder.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":191,"url":"https:\/\/www.jitendrazaa.com\/blog\/microsoft\/net\/datagrid-example-part-1\/","url_meta":{"origin":2380,"position":1},"title":"DataGrid Example &#8211; Part 1","author":"Jitendra","date":"May 18, 2010","format":false,"excerpt":"For the basics of DataGrid please refer this post: https:\/\/jitendrazaa.com\/blog\/?p=188 In this example, i will explain the basics of DataGrid control like Theming, Databinding etc. We will start our example with creating the SQL Express database of Employee which will contain the following fields : Id, FName, LName, Email. Now\u2026","rel":"","context":"In &quot;ASP.NET&quot;","block_context":{"text":"ASP.NET","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/microsoft\/net\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2010\/05\/Employee.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":71,"url":"https:\/\/www.jitendrazaa.com\/blog\/webtech\/web\/style-file-upload-control-in-asp-html\/","url_meta":{"origin":2380,"position":2},"title":"Style File upload control in ASP \/ HTML","author":"Jitendra","date":"May 10, 2010","format":false,"excerpt":"As most of us know that we cannot style the file upload control to much level, still we can give it a stunning effect with the help of CSS. There is nothing in code to explain. I took three upload control and one button to give effect. Lets say upload\u2026","rel":"","context":"In &quot;HTML&quot;","block_context":{"text":"HTML","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/webtech\/web\/"},"img":{"alt_text":"Output in Chrom","src":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2010\/05\/Output-in-Chrom-300x82.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":2299,"url":"https:\/\/www.jitendrazaa.com\/blog\/microsoft\/net\/tutorial-read-and-export-excel-file-in-asp-net-using-c\/","url_meta":{"origin":2380,"position":3},"title":"Tutorial &#8211; Read and export excel file in ASP.Net  using C#","author":"Jitendra","date":"July 29, 2011","format":false,"excerpt":"Tutorial - Read and export excel file in ASP.Net using C#","rel":"","context":"In &quot;ASP.NET&quot;","block_context":{"text":"ASP.NET","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/microsoft\/net\/"},"img":{"alt_text":"Read And Export Excel in ASP.Net","src":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2011\/07\/Read-And-Export-Excel-in-ASP.Net_.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":827,"url":"https:\/\/www.jitendrazaa.com\/blog\/webtech\/add-css-programatically-in-asp-net\/","url_meta":{"origin":2380,"position":4},"title":"Add CSS Programatically in ASP.NET","author":"Jitendra","date":"September 3, 2010","format":false,"excerpt":"Tutorial on adding the CSS file dynamically in ASP.NET and C# \/ VB.Net","rel":"","context":"In &quot;ASP.NET&quot;","block_context":{"text":"ASP.NET","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/microsoft\/net\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1527,"url":"https:\/\/www.jitendrazaa.com\/blog\/microsoft\/net\/ajax-based-multiselect-jquery-autocomplete-control-in-asp-net\/","url_meta":{"origin":2380,"position":5},"title":"Ajax Based Multiselect JQuery Autocomplete Control in ASP.Net","author":"Jitendra","date":"February 19, 2011","format":false,"excerpt":"Tutorial on creating Ajax Based Multiselect JQuery Autocomplete User Control in ASP.Net","rel":"","context":"In &quot;ASP.NET&quot;","block_context":{"text":"ASP.NET","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/microsoft\/net\/"},"img":{"alt_text":"Ajax Based Multiselect JQuery Autocomplete Control in ASP.Net","src":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2011\/02\/Ajax-Based-Multiselect-JQuery-Autocomplete-Control-in-ASP.Net_.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts\/2380","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/comments?post=2380"}],"version-history":[{"count":0,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts\/2380\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/media?parent=2380"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/categories?post=2380"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/tags?post=2380"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}