views:

504

answers:

2
rbnResubmission.Items.FindByValue("Yes").Attributes.Add("onclick", "getCheckedRadioFieldResubmission(this)");
rbnResubmission.Items.FindByValue("No").Attributes.Add("onclick", "getCheckedRadioFieldResubmission(this)");

So I have these click events for showing rows in a table - that part works fine.

Here's an example of what the code does (I'm not showing the "No" option)

function getCheckedRadioFieldResubmission(radio){
    if(radio.value == "Yes"){
         document.getElementById('<%=ApprovingInstituteRow.ClientID%>').style.display ="block";
         document.getElementById('<%=ApprovalNumberRow.ClientID%>').style.display ="block";
         document.getElementById('<%=IRBApprovalRow.ClientID%>').style.display ="block";
         document.getElementById('<%=ExpectedDateRow.ClientID%>').style.display ="none";
     }
}

The form needs to go through validation, and if there's any problems, because the event to show these rows only happens from "onclick" - they will disappear upon postback. what can I change to make them appear permanently?

A: 

I'm guessing you're databinding the radio button list during onLoad. You have to rebind it on postback.

Mike Robinson
A: 

You'll probably want to add the same functionality of your getCheckedRadioFieldResubmission function into the onload event of the html <body> tag. However, since the this object will refer to the body element and not the radio, you'll need to put something of this sort in there to find the radio:

var radio = document.getElementById('radio_id');

This will work if your radio list has a maintained state. As in, it keeps it's state after Post Back.

regex