Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
looking back at your statement what exactly to you mean by [tt]enable the requiredfield validator[/tt]? does the error message not display? does the validation not execute? something else?lin73 said:Radiobuttonlist1 is required, and when Radiobuttonlist1 index 2 is selected the Radiobuttonlist2 should be required, but since there is no postback I can't enable the requiredfield validator for Radiobuttonlist2 when the Radiobuttonlist1 index 2 has been selected
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml"[/URL] >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<br />
<br />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
</asp:RadioButtonList>
<asp:RadioButtonList ID="RadioButtonList2" runat="server" Enabled="False">
<asp:ListItem>a</asp:ListItem>
<asp:ListItem>b</asp:ListItem>
<asp:ListItem>c</asp:ListItem>
</asp:RadioButtonList>
</ContentTemplate>
</asp:UpdatePanel>
<br />
<asp:UpdatePanel ID="UpdatePanel3" runat="server">
<ContentTemplate>
<asp:RequiredFieldValidator ControlToValidate="RadioButtonList1" ID="RequiredFieldValidator1" runat="server" ErrorMessage="rbl 1 is required" Display="Dynamic"></asp:RequiredFieldValidator>
<asp:RequiredFieldValidator Enabled="false" ControlToValidate="RadioButtonList2" ID="RequiredFieldValidator2" runat="server" ErrorMessage="rbl 2 is required" Display="Dynamic"></asp:RequiredFieldValidator>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<br />
<br />
</div>
<asp:Button ID="Button1" runat="server" Text="Button" />
</form>
</body>
</html>
Partial Class Default2
Inherits System.Web.UI.Page
Protected Sub RadioButtonList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
If RadioButtonList1.SelectedIndex = 2 Then
RadioButtonList2.Enabled = True
RequiredFieldValidator2.Enabled = True
Else
RadioButtonList2.Enabled = False
RequiredFieldValidator2.Enabled = False
End If
End Sub
End Class