title: how to place a button on crm 2011 form.
body: <p>I want to place a button on CRM 2011 form.</p>
  
  <pre><code>function create_button(fldName, btnLabel, btnWidth, evt) 
  {
  try{
  fldName = "inmate_button_submit";
  btnLable="Click Me";
  // btnWidth="200px";
  
  
  var btn = '&lt;button class="ms-crm-Button" onclick="evt()" style="width:50px" id="' +      fldName + '" onmouseover="Mscrm.ButtonUtils.hoverOn(this);"  onmouseout="Mscrm.ButtonUtils.hoverOff(this);" &gt;Click Me&lt;/button&gt;';
  
  var ctrl = null;
  
  try {
      ctrl = Xrm.Page.ui.controls.get(fldName).get_chromeElement()[0];
  } catch (e) {
      ctrl = Xrm.Page.ui.controls.get(fldName)._control.get_element();
  }
  
  // Add the new button
  ctrl.innerHTML += btn;
  
  // Hide the textbox
  ctrl.children[0].style.display = 'none';
  ctrl.children[1].style.display = 'none';
  
  // Hide the label
  Xrm.Page.ui.controls.get(fldName).setLabel(btnLable);
  
  // Add Event to the newly created button
   ctrl.children[0].attachEvent('onclick', evt);
  
  }
  catch(e){alert(e.description);}
    }
  function evt()
  {
  alert("You have clicked me!!");
  }
  </code></pre>
  
  <p>The above is my following code which places the button on the form. When i click on the button, after showing the alert crm gives me the following error. </p>
  
  <p><em>ERROR
  An error has occurred.
  Try this action again. If the problem continues, check the Microsoft Dynamics CRM Community or you for solutions or contact....</em></p>
  
  <p>I have no idea why this is happening. Any help guys?</p>