Monday, December 2, 2013

ASP.NET jQuery $find() not working in onclick() event of radio button

In an application where i want trigger the onclick event of radio button that has a $find() method, which will retrieve the radio button's value, the code below doesn't work.
 <input type="radio" id="rb1" name="format" value="format2" runat="server"  
             onclick="$find('<%=dpe1.ClientID %>').populate(this.value);" />d.m.y  
  <input type="radio" id="rb2" name="format" value="format3" runat="server"  
             onclick="$find('<%=dpe1.ClientID %>').populate(this.value);" />y/m/d  
where dpe1 is a DynamicPopulateExtender Ajax Extender.The solution I made was to remove the populate logic and transfer it to a javascript function. Here's the revised code:
 //javascript code  
 function rbFunction() {  
     //$find('<%=dpe1.ClientID %>').populate($("input:radio:checked").val());  
 }  
 //html code  
 <input type="radio" id="rb2" name="format" value="format2" runat="server"  
       onclick="javascript:rbFunction()" />d.m.y  
 <input type="radio" id="rb3" name="format" value="format3" runat="server"  
       onclick="javascript:rbFunction()" />y/m/d  
Cheers!

0 comments:

Post a Comment