Click here to Skip to main content
13,143,424 members (34,952 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
Hi,
I want to validate texbox on radio button on change event but my page is getting post back at the time of radio button onchange event
so, how can i prevent page post back
Please help

rajp11
Posted 18-May-12 0:50am
rajsp11307
Comments
Stephen Hewison 2 18-May-12 7:03am
   
Could you post the ASPX for the radio button? My guess is that you've tried writing javascript into the onchange attribute. The onchange attribute for the server side control creates a postback. You need to do something like this in you server side code.

ctlRadioButton.Attributes.Add("onchange", "alert('test');");

This will write the alert('test'); command to the HTML rendering as a client event.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

you can use onchange event that is client side event you can call javascript and check whatever

function Checking() {
           alert('test')
           }




<asp:radiobutton id="RadioButton1" runat="server" onchange="Checking()" xmlns:asp="#unknown" />
  Permalink  
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

First there should not autopostback="true" in your Radio button
<tr>
                                       <td>
                                           <asp:radiobutton id="Radio1" checked="true" runat="server" text="Text" groupname="rd" xmlns:asp="#unknown" />
                                       </td>
                                       <td>
                                           <asp:radiobutton id="Radio2" runat="server" text="Image" groupname="rd" xmlns:asp="#unknown" />
                                       </td>
                                   </tr>

then using jQuery it will get like this:
$(document).ready(function () {
           $('#Radio1').change(function () {
              //do something here
           });
           $('#Radio2').change(function () {
             //do some more stuff here
           });
       });
  Permalink  
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

Go this you will get more info:

Click Here
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 4

Hello friend go on this website................
[^][^]
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web04 | 2.8.170915.1 | Last Updated 19 May 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100