Hello Andreas,
You can write your own custom client-side function, which validates the buttons based on their state. I have made scenario, similar to the case you described.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<script type="text/javascript">
function CheckRadios(sender, args) {
var radionButton1 = $find("<%= RadButton1.ClientID %>");
var radionButton2 = $find("<%= RadButton2.ClientID %>");
// get reference to clinet-side objects of the radio buttons
var messageHolder = document.getElementById('ErrorMessage');
// get reference to the object containing the message
if (!radionButton1.get_checked() && !radionButton2.get_checked()) { // see if radionButton1 and radionButton2 are both unchecked
messageHolder.innerHTML = "Choose something.";
messageHolder.style.color = "Red";
// set the text and color of the message
args.set_cancel(true);
// click event canceled, which stops postback
}
}
</script>
<telerik:RadButton ID="RadButton1" runat="server" Text="Choise 1" ButtonType="ToggleButton"
ToggleType="Radio" GroupName="Time" AutoPostBack="false">
</telerik:RadButton>
<telerik:RadButton ID="RadButton2" runat="server" Text="Choise 2" ButtonType="ToggleButton"
ToggleType="Radio" GroupName="Time" AutoPostBack="false">
</telerik:RadButton>
<br />
<span id="ErrorMessage" class="message"></span>
<br />
<telerik:RadButton ID="RadButton3" runat="server" Text="Submit" OnClientClicking="CheckRadios">
</telerik:RadButton>
</div>
</form>
</body>
</html>
In addition to the two
RadioButtons, a new
RadButton, which triggers Postback, is added. In the client-side handler of
RadButton's event
OnClientClicking, the state of the radio buttons is checked. If both controls are in unchecked state a warning message is displayed and the event is canceled, meaning that Postback doesn't occur.
You can find more information about
RadButton's client-side basis
here and description of the used event
here.
Best wishes,
Slav
the Telerik team