开发者

ASP.NET How to call my function when the selected index changes in radio button list without updating the whole page?

开发者 https://www.devze.com 2022-12-23 11:58 出处:网络
I have a table in my form, wher开发者_运维百科e I put n-rows, every row contains 1 RadioButtonList, when user select the item in RadioButtonList, I need to get the index of selected Item, without upda

I have a table in my form, wher开发者_运维百科e I put n-rows, every row contains 1 RadioButtonList, when user select the item in RadioButtonList, I need to get the index of selected Item, without updating the page.


A bit of jQuery would work:

$('input[type=radio]').click( function() {
     var selectedIndex = $('input[type=radio]').index(this);
     ...do something with the index...
});

This will give you the zero-based index of the clicked radio button in the set. If you have other radio buttons on the page, use a selector that restricts them to the container (table) that they are in.


the simplest way would be to put it into an updatepanel using the AJAX.Net libraries.

The harder way would be to roll out your own ajax functionality that performs everything you want to happen when the selection changes on the radio button.

0

精彩评论

暂无评论...
验证码 换一张
取 消