Server validate+date picker

4 posts, 1 answers
  1. Tina
    Tina avatar
    130 posts
    Member since:
    Jul 2011

    Posted 19 Apr 2012 Link to this post

    Here is the code I am trying.How to access datepicker in server validate?
    <EditItemTemplate>
                                <telerik:RadDatePicker ID="StartDate" runat="server">
                                </telerik:RadDatePicker
    <asp:CustomValidator ControlToValidate="StartDate" ID="CustomValidator2" runat="server"
    ErrorMessage="Please select" OnServerValidate="CustomValidator2_ServerValidate"> </asp:CustomValidator>
    <EditItemTemplate>
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 19 Apr 2012 Link to this post

    Hi Tina,

    Try the following code to access RadDatePicker in ServerValidate.

    C#:
    protected void CustomValidator2_ServerValidate(object source, ServerValidateEventArgs args)
        {
            CustomValidator validate = (CustomValidator)source;
            GridEditableItem item = (GridEditableItem)validate.NamingContainer;
            RadDatePicker pkr = (RadDatePicker)item.FindControl("StartDate");
        }

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Tina
    Tina avatar
    130 posts
    Member since:
    Jul 2011

    Posted 20 Apr 2012 Link to this post

    When I am hiding the field using this line of code item["id"].Visible = false; in edit mode, it hides the textbox, but shows the label field.I want to hide the label also?
  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 20 Apr 2012 Link to this post

    Hi Tina,

    Try the following code to hide the Label as well as TextBox.

    C#:
    protected void radgrid1_ItemDataBound(object sender, GridItemEventArgs e)
       {
         if (e.Item is GridEditableItem && e.Item.IsInEditMode)
           {
               GridEditableItem item = (GridEditableItem)e.Item;
               item["id"].Parent.Visible = false;
           }
       }

    Thanks,
    Princy.
Back to Top