I am using the custom advance form template with my scheduler,
and have added a few custom resources , i want to add required field validator's to these resources!
However i am struggling with this as the validator cannot find the control.
Can anyone give me some help with this or point me in the direction of a good way/method of validating resources please.
Many Thanks in advance
Regards
Darren
20 Answers, 1 is accepted
The easiest and neatest solution in my opinion is to add a RequiredFieldValidator in the ResourceControl user control and set AllowCustomText="true" for RadComboBox:
ResourceControl.ascx
<
asp:Label
runat
=
"server"
ID
=
"ResourceLabel"
AssociatedControlID
=
"ResourceValue"
Text='<%# Label %>' CssClass="rsAdvResourceLabel" />
<!--
-->
<
telerik:RadComboBox
runat
=
"server"
ID
=
"ResourceValue"
CssClass
=
"rsAdvResourceValue"
AllowCustomText
=
"true"
Skin='<%# Skin %>' />
<
asp:RequiredFieldValidator
ID
=
"ResourceValidator"
runat
=
"server"
ControlToValidate
=
"ResourceValue"
EnableClientScript
=
"true"
Display
=
"None"
CssClass
=
"rsValidatorMsg"
>
</
asp:RequiredFieldValidator
>
In code behind, you can comment the default '-' first item:
private
void
MarkSelectedResource()
{
//ResourceValue.Items.Insert(0, new RadComboBoxItem("-", "NULL"));
Resource res = Appointment.Resources.GetResourceByType(Type);
if
(res !=
null
)
{
ResourceValue.SelectedValue = SerializeResourceKey(res.Key);
}
}
Attached is a sample for reference.
All the best,
Peter
the Telerik team

Thanks very much for your help.
Regards
Darren

I have exactly the same problem, and I've tried implementing the solution suggested by Peter from the Telerik team, but I can't get it to work. If I leave my resource value blank I get an exception from DeserializeResourceKey(string key) saying that the key cannot be null.
I've downloaded the sample project too, but it doesn't work either. Can someone verify that it is OK?
Regards, Jill-Connie Lorentsen
Please, tell me which version of Telerik controls do you use so that I can test the sample with it.
Kind regards,
Peter
the Telerik team

Due to some rendering changes with the controls for Q2 2012, the AdvancedForm user control and the AdvancedForm.js also had to be updated. I have done the necessary changes in the attached modified sample. Please, test it and let me know if you have further questions or concerns.
Regards,
Peter
the Telerik team


But, I don't get those warning triangles in my advanced form? I am new to asp, and I don't get where it comes from? I've tried to look for differences in my code and yours, but I can't figure it out. And it is not only in my resource controls, even the subject field doesn't get the triangle. The advanced form does detect that there is something wrong, as it doesn't close, but no error is shown.
Another thing is that in the start and end time fields the warning triangle flickers for a split second as I press Save, even though the times are fine.
Code for the Subject field:
<
telerik:RadTextBox
runat
=
"server"
ID
=
"SubjectText"
Width
=
"100%"
Label='<%# Owner.Localization.AdvancedSubject + ":" %>'
EnableSingleInputRendering="false" />
<
asp:RequiredFieldValidator
runat
=
"server"
ID
=
"SubjectValidator"
ControlToValidate
=
"SubjectText"
EnableClientScript
=
"true"
Display
=
"None"
CssClass
=
"rsValidatorMsg"
/>
and the resource control:
<
asp:Label
runat
=
"server"
ID
=
"ResourceLabel"
AssociatedControlID
=
"ResourceValue"
Text='<%# Label %>' CssClass="rsAdvResourceLabel" />
<!--
-->
<
telerik:RadComboBox
runat
=
"server"
ID
=
"ResourceValue"
CssClass
=
"rsAdvResourceValue"
Skin='<%# Skin %>' AllowCustomText="true" />
<
asp:RequiredFieldValidator
ID
=
"ResourceValidator"
runat
=
"server"
ControlToValidate
=
"ResourceValue"
EnableClientScript
=
"true"
Display
=
"None"
CssClass
=
"rsValidatorMsg"
></
asp:RequiredFieldValidator
>
Any ideas?
Regards, Jill-Connie Lorentsen
Can you verify that the code in your AdvancedForm.js file is the same as the one in the sample I sent you? Other than that, I am not sure what could be causing this problem at your side.
Greetings,
Peter
the Telerik team

Yes, they are identical.
As I said, I am new to asp, and I am new to javascript too. How can I debug the .js file?
I don't think the problem is in my AdvancedForm.ascx, rather in my Default.aspx, which contains the RadScheduler. I tried putting all the files in the same web site, and and I got the desired behavior in both mine and your Advanced form when it was opened from the RadSceduler in your main page, and they both fail when opened from my default(main) page. I'll continue searching...
Regards, Jill-Connie
If you can send us a simple working sample of the issue via a support ticket, we will debug it locally and try to help you.
Greetings,
Peter
the Telerik team

I'll try to do that.
But, if I remove the UpdatedControls from the RadAjaxManager it works fine. Any idea why it is so?
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"RadScheduler1"
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManager
>
I don't have an idea why removing RadAjaxManager solves the problem. I will wait for your sample to be able to make further suggestions.
Regards,
Peter
the Telerik team

Now I have modified my project, - but I can't figure out how to submit a support ticket? Shouldn't there be a "Submit support ticket" link on the page which shows my support tickets?
Regards, Jill-Connie
Please, see this video capture on how to send a ticket - http://screencast.com/t/6apxWOuNDAT.
Kind regards,
Peter
the Telerik team

I updated your latest example locally to include the validator on the resourcecontrol... I get the same error !!!!

In my case the problem was that the RadScheduler was ajaxified by both RadAjaxPanel and RadAjaxManager. Changing the RadAjaxPanel to an asp:panel fixed the problem with the missing triangles.
Other that that the newest version of the advanced form including the .js solved the issue with the exception from DeserializeResourceKey(string key) in my case

I have inspected the scenario once again and it worked properly at my side as well with the latest version. Would you please share the exact code which is different at your side so we can be more helpful?
Please check if there is some differences in the SQL DataTables used at your side as well.
Plamen
the Telerik team

adding this to the resourcecontrol seems not to do anything
<asp:RequiredFieldValidator ID="ResourceValidator" runat="server" ControlToValidate="ResourceValue"
EnableClientScript="true" Display="None" CssClass="rsValidatorMsg"> </asp:RequiredFieldValidator>
I also commented out this lineResourceValue.Items.Insert(0, new RadComboBoxItem("-", "NULL"))
in MarkSelectrdResources so the '-' would not show
If you try the demo with these changes you should get
Error: Sys.WebForms.PageRequestManagerServerErrorException: Value cannot be null.
Parameter name: inputString