Add an onclick event to the radiobuttonlist item.

Source: Internet
Author: User

Method: Use radiobuttonlistPrerenderThe onclick event is added for each item in the radiobuttonlist bound to the event.

Example: add an onclick event to the controls in radiobuttonlist to display and hide the front-end controls.

Code:

///   <Summary>
/// Add JS events
///   </Summary>
///   <Param name = "sender"> </param>
///   <Param name = "E"> </param>
Protected   Void Rblisdescription_prerender ( Object Sender, eventargs E)
{
Foreach (Listitem item In Rblisdescription. Items)
{
Item. Attributes. Add ( " Onclick " , " Javascript: rdbnoclick (); " );
}
}

// When the radio variable is used, the display content is changed.
Function Rdbnoclick ()
{
VaR Vdescriptiontitle = Document. getelementbyid ( ' Trdescriptiontitle ' );
VaR Visdescription = Document. getelementbyid ( " Txbisdescription " );
If (Vdescriptiontitle ! = Null )
{
VaR Vrblisdescription = Document. getelementbyid ( " Rblisdescription " );
VaR RBS = Vrblisdescription. getelementsbytagname ( " Input " );
For ( VaR I =   0 ; I < RBS. length; I ++ )
{
If (RBS [I]. Checked)
{
VaR Text = Vrblisdescription. cells [I]. innertext;
VaR Vrdvalue = RBS [I]. value;
// Add other Descriptive values to textbox for judgment during loading
If (Visdescription ! = Null )
{
Visdescription. Value = Vrdvalue;
}

// Determines whether to display "other instructions" based on "whether other instructions are required". 0 indicates not to display
If (Vrdvalue = 0 )
{
Vdescriptiontitle. style. Display = ' None ' ;
}
Else
{
Vdescriptiontitle. style. Display = ' Block ' ;
}
}
}
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.