lundi 24 avril 2017

C#/Web Radio Button Limiting Sets

I have never done this and am not even sure where to post. I'm sorry. I added another section to this set of three radio buttons on a really old website. I believe I named it rdoSheetfedPressMats0 Is this the correct code? It is still allowing me to select more than one. What I added is in bold. Any help would be appreciated. Thank you

private bool preventMoreThanOnePressMatSelection()
{
    if (rdoSheetfedPressMats.SelectedIndex != -1 && rdoWebPressMats.SelectedIndex != -1 && rdoSheetfedPressMats0.SelectedIndex != -1)
    {
        rdoSheetfedPressMats.SelectedIndex = -1;
        rdoWebPressMats.SelectedIndex = -1;
        rdoSheetfedPressMats0.SelectedIndex = -1;

        lblRawMatsSelect.Text = "You can only select one raw material type.";
        lblAdditionalValSum.Text += "<br />- You can only select one raw material type.";
        lblRawMatsSelect.ForeColor = Color.Red;
        lblRawMatsSelect.Font.Italic = lblRawMatsSelect.Font.Bold = true;
        return false;
    }
    else if (rdoSheetfedPressMats.SelectedIndex == -1 && rdoWebPressMats.SelectedIndex == -1 && chkUsedInPress.Checked)
    {
        lblRawMatsSelect.Text = "Select a raw material type.";
        lblAdditionalValSum.Text += "<br />- Select a raw material type.";
        lblRawMatsSelect.ForeColor = Color.Red;
        lblRawMatsSelect.Font.Italic = lblRawMatsSelect.Font.Bold = true;
        return false;
    }
    else
    {
        lblRawMatsSelect.Text = string.Empty;
        return true;
    }
}




Aucun commentaire:

Enregistrer un commentaire