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 ' ;
}
}
}
}
}