How to allow blank subject?

7 posts, 0 answers
  1. Steele
    Steele avatar
    96 posts
    Member since:
    Mar 2008

    Posted 11 Mar 2009 Link to this post

    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.
  2. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 13 Mar 2009 Link to this post

    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.
  3. Steele
    Steele avatar
    96 posts
    Member since:
    Mar 2008

    Posted 18 Mar 2009 Link to this post

    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.
  4. Steele
    Steele avatar
    96 posts
    Member since:
    Mar 2008

    Posted 18 Mar 2009 Link to this post

    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.
  5. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 19 Mar 2009 Link to this post

    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.
  6. Henric
    Henric avatar
    11 posts
    Member since:
    Nov 2008

    Posted 14 Mar 2011 Link to this post

    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?

  7. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 15 Mar 2011 Link to this post

    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!
Back to Top