Wednesday, March 12, 2014

Use anchor to pop up window

Using an anchor to pop-up a window with JavaScript
Anchor tag:
<a href="javascript:popWindow('http://www.google.com');">Pop Window</a>

JavaScript:
<script type="text/javascript">
   function popWindow(hrefTarget) { 
   // Pop up the window
     window.open(hrefTarget, "_blank", "width=463,height=500,resizable=yes");
   }</script>

Alternatively, returning a false will prevent the anchor from linking:
<a href='www.google.com' onclick='FunctionCall(); return false;'>Pop Window</a>

Thursday, March 6, 2014

Using RadioButton within Repeater

To turn off radio buttons within a Repeater when a selection is made, the javascript below will assist.


<script language="javascript" type="text/javascript">  
function RB_CheckChanged(current) {
  for (i = 0; i < document.forms[0].elements.length; i++) {
      elm = document.forms[0].elements[i];
      if (elm.type == 'radio') {
         elm.checked = false;
       }
   }
   current.checked = true;
}
</script>



<asp:Repeater runat="server" ID="RBRptr">                                               
   <ItemTemplate>
     :RadioButton runat="server" ID="Rb" onclick="RB_CheckChanged(this);" Text='<%  #DataBinder.Eval(Container.DataItem, "name")%>' />
  </ItemTemplate>                                          
</asp:Repeater>