开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜