This is a migrated thread and some comments may be shown as answers.

How to allow blank subject?

6 Answers 105 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Steele
Top achievements
Rank 1
Steele asked on 11 Mar 2009, 05:36 AM
Hi All,
I am just trying to remove the validation from the AdvancedInsert and Edit templates that require that a subject must be entered.
I want the subject to be optional.
Anybody know how to do this?
Thanks,
Steele.

6 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 13 Mar 2009, 02:10 PM
Hello Steele,

You can disable the required field validator in FormCreated event like this:

protected void RadScheduler1_FormCreated(object sender, SchedulerFormCreatedEventArgs e) 
    TextBox subject = e.Container.FindControl("Subject"as TextBox; 
    RequiredFieldValidator subjectValidator = e.Container.FindControl("SubjectValidator"as RequiredFieldValidator; 
 
    if (subject != null && subjectValidator != null
    { 
        subjectValidator.Enabled = false
    } 

Also, you need to ensure that the corresponding database field allows NULL values.
If you do not want that you can set the ConvertEmptyStringToNull of the Subject update parameter to False:

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:TelerikConnectionString %>" 
    UpdateCommand="Update Appointments SET Subject=@Subject WHERE ID=@id" 
    SelectCommand="SELECT * FROM [Appointments]"
    <UpdateParameters> 
        <asp:Parameter Name="id" Type="int32" /> 
        <asp:Parameter Name="Subject" Type="string" ConvertEmptyStringToNull="false" /> 
    </UpdateParameters> 
</asp:SqlDataSource> 

I hope this helps.

Sincerely yours,
Veselin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Steele
Top achievements
Rank 1
answered on 19 Mar 2009, 12:09 AM
Thanks for the reply Veselin, but unfortunately, setting Enabled to false didn't actually work.  After hitting save, the callback occurs and the Validator message is displayed.
It seems that the changes made in the FormCreated event are ignored.  I tried removing the validator control completely in the FormCreated event (which I confirmed while stepping through debugging), but it still displays after hitting save.
Very strange.
Do you have any further ideas?
Thanks,
Steele.
0
Steele
Top achievements
Rank 1
answered on 19 Mar 2009, 01:23 AM
I have had no further luck, just more confirmation that the Validator does not seem to take on the values of the changes made in the code behind - like the template is being rebuilt during the validation callback on save.
Even if I try to change the message that appears in the validation error box, the new string does not appear.
Anyone else had trouble with this?
Steele.
0
Peter
Telerik team
answered on 19 Mar 2009, 01:49 PM
Hi Steele,

I can send you our test project if you think this is going to help you overcome the problem. Or, you can open a support ticket and send us a demo of the issue yourself. We will debug it locally and try to find the cause of the problem.

Kind regards,
Peter
the Telerik team


Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Henric
Top achievements
Rank 1
answered on 14 Mar 2011, 03:34 PM
I'm picking up this thread since I need this also...
The problem is the above solutions doesn't work for me either. Is there any solution on this one elsewhere?

EDIT:
I can now insert appointments with empty subject (NULL). I added the attribute OnFormCreated="RadScheduler1_FormCreated". 

 

However, appointments with subject=NULL does not show in the scheduler... Change subject to empty string and they show again. Is this correct?

0
Peter
Telerik team
answered on 15 Mar 2011, 10:17 AM
Hello Henric,

Yes, the Subject field is mandatory (Data Binding). However, empty string is still allowed if you can bypass the built-in validation.


Best wishes,
Peter
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
Scheduler
Asked by
Steele
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Steele
Top achievements
Rank 1
Peter
Telerik team
Henric
Top achievements
Rank 1
Share this question
or