RadAjax controls fully support server and client-side validation.
This example demonstrates how to achieve the desired functionality in a straightforward and simple way with the RadAjaxPanel control. You can also use the RadAjaxManager for the same purpose. In order to use the server-side validation, you must add the panels with the validator controls in the UpdatedControls collection for the Register button:
C# code:
private
void
RegisterButton_Click(
object
sender, System.EventArgs e)
{
...
if
(RadioButtonList1.SelectedIndex == 1)
// Update the panels with validators only if server-side validation is performed.
{
// RadAjaxManager1.AjaxSettings[0] specifies the settings for Ajax requests initiated by the Register Button control
AjaxUpdatedControl updatedControl1 =
new
AjaxUpdatedControl();
updatedControl1.ControlID = Panel1.ClientID;
RadAjaxManager1.AjaxSettings[0].UpdatedControls.Add(updatedControl1);
AjaxUpdatedControl updatedControl2 =
new
AjaxUpdatedControl();
updatedControl2.ControlID = Panel2.ClientID;
RadAjaxManager1.AjaxSettings[0].UpdatedControls.Add(updatedControl2); AjaxUpdatedControl updatedControl3 =
new
AjaxUpdatedControl();
updatedControl3.ControlID = Panel3.ClientID;
RadAjaxManager1.AjaxSettings[0].UpdatedControls.Add(updatedControl3);
}
}
VB.NET code:
Private
Sub
RegisterButton_Click(sender
As
Object
, e
As
System.EventArgs)
Handles
RegisterButton.Click
...
If
RadioButtonList1.SelectedIndex = 1
Then
' Update the panels with validators only if server-side validation is performed.
' RadAjaxManager1.AjaxSettings(0) specifies the settings for Ajax requests initiated by the Register Button control
Dim
updatedControl1
As
New
AjaxUpdatedControl()
updatedControl1.ControlID = Panel1.ClientID
RadAjaxManager1.AjaxSettings(0).UpdatedControls.Add()
(updatedControl1)
Dim
updatedControl2
As
New
AjaxUpdatedControl()
updatedControl2.ControlID = Panel2.ClientID
RadAjaxManager1.AjaxSettings(0).UpdatedControls.Add()
(updatedControl2)
Dim
updatedControl3
As
New
AjaxUpdatedControl()
updatedControl3.ControlID = Panel3.ClientID
RadAjaxManager1.AjaxSettings(0).UpdatedControls.Add()
(updatedControl3)
End
If
End
Sub