title: set linkbutton as default button for asp:panel in asp.net
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/938957/link-button-on-the-page-and-set-it-as-default-button-work-fine-in-ie-but-not-in">Link Button on the page and set it as default button, work fine in IE but not in Mozila</a>  </p>
  </blockquote>
  
  
  
  <p>How to set linkbutton as default button for asp:panel in asp.net? I know a button can be set as default but my application uses linkbuttons for all forms. Any suggestion how it can be done.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Now i tried this,
  It works in firefox as well but my javascript validation (ie) onclient click of my linkbutton doesn't work why?</p>
  
  <pre><code>var __defaultFired = false;
  
          function WebForm_FireDefaultButton(event, target) {
              var element = event.target || event.srcElement;
  
              if (!__defaultFired &amp;&amp; event.keyCode == 13 &amp;&amp; !(element &amp;&amp; (element.tagName.toLowerCase() == "textarea"))) {
                  var defaultButton;
  
                  if (__nonMSDOMBrowser)
                      defaultButton = document.getElementById(target);
                  else
                      defaultButton = document.all[target];
  
                  if (defaultButton) {
                      if (typeof (defaultButton.click) != "undefined")
                          defaultButton.click();
                      else
                          eval(unescape(defaultButton.href.replace("javascript:", "")));
  
                      event.cancelBubble = true;
  
                      if (event.stopPropagation) event.stopPropagation();
                      return false;
                  }
              }
              return true;
          }
  </code></pre>
  
  <p><strong>Second EDIT:</strong></p>
  
  <p>I was able make my custom linkbutton control work but couldn't able to hook OnClientClick to it. Source <a href="http://kpumuk.info/asp-net/using-panel-defaultbutton-property-with-linkbutton-control-in-asp-net/" rel="nofollow noreferrer">using-panel-defaultbutton-property-with-linkbutton-control-in-asp-net</a>. </p>
  
  <p>and i did this,</p>
  
  <pre><code>&lt;%@ Register Namespace="App_Code" TagPrefix="ac" %&gt;
  &lt;asp:Label runat="server" ID="lblHello" /&gt;
  &lt;asp:Panel runat="server" DefaultButton="lbHello"&gt;
      First name: &lt;asp:TextBox runat="server" ID="txtFirstName" /&gt;
      &lt;ac:LinkButtonDefault ID="lbHello" runat="server" Text="Click me" 
          OnClientClick="javascript:alert('hai');" OnClick="lbHello_Click" /&gt;
  &lt;/asp:Panel&gt;
  </code></pre>
  
  <p>My Clientside function doesn't work why? Any suggestion.</p>