title: Run JavaScript code at ASP.NET page load
body: <p>I have a radiobox <code>&lt;asp:RadioButtonList CssClass="list" Style="width: 150px" 
      ID="rdo_RSD_ExcerciseRoT" runat="server"
      Font-Bold="false" RepeatDirection="Horizontal" RepeatLayout="Table" 
      TextAlign="Left" &gt;
      &lt;asp:ListItem Text="Yes"  onclick="en();" Value="Y"&gt;&lt;/asp:ListItem&gt;
      &lt;asp:ListItem Text="No" onclick="dis();" Value="N" Selected="True"&gt;&lt;/asp:ListItem&gt;
  &lt;/asp:RadioButtonList&gt;
  </code> </p>
  
  <p>AS you may see second listitem is selected by default. But issue is, when my page is getting load <code>dis()</code> is not getting called. I want to run <code>dis()</code> on page load too.</p>
  
  <p>I tried google, some blogs suggest the use of <strong><a href="http://msdn.microsoft.com/en-us/library/system.web.ui.page.registerstartupscript(VS.71).aspx" rel="nofollow noreferrer">Page.RegisterStartupScript Method</a></strong>. But I dont exactly know what is the problem and why we should use this above mentioned method. I would appreciate if someone please tell me why this function is not getting called and how to call it.</p>
  
  <p><strong>Edit:</strong> I am giving Javascript code also, if it helps.</p>
  
  <pre><code>    &lt;script type="text/javascript"&gt;
      function dis()
      {
          ValidatorEnable(document.getElementById('&lt;%=RequiredFieldValidator32.ClientID%&gt;'), false);
      }
  
      function en()
      {
          ValidatorEnable(document.getElementById('&lt;%=RequiredFieldValidator32.ClientID%&gt;'), true);
      }
  
  
  &lt;/script&gt;
  </code></pre>