locked
"Type 'Microsoft.SharePoint.WebControls.DateTimeControl' does not have a public property named 'TextBox'." RRS feed

  • Question

  • Hi

    I am working on Project in which we are upgrading one old SharePoint portal from MOSS 2007 to SharePoint 2010. So far everything is working fine except custom web part which have “SharePoint DateTimeControl” used in it.

    whenever I try to run this I get error message "Type 'Microsoft.SharePoint.WebControls.DateTimeControl' does not have a public property named 'TextBox'."

    Following is the snap of actual code.

     <SharePoint:DateTimeControl ID="DTCFrom" runat="server" DateOnly="true" Visible="false">
                     
                                <asp:TextBox ID="DateTimeControl2Date" runat="server" MaxLength="45" CssClass="ms-input"></asp:TextBox>
                                   
                                <asp:DropDownList runat="server" ID="DateTimeControl2DateHours">
                                        <asp:ListItem Selected="True" Value="12 AM">12 AM</asp:ListItem>
                                        <asp:ListItem Value="1 AM">1 AM</asp:ListItem>
                                        <asp:ListItem Value="2 AM">2 AM</asp:ListItem>
                                        <asp:ListItem Value="3 AM">3 AM</asp:ListItem>

    Above code is working fine on existing MOSS 2007 portal so I am not supposed to modify this while migrating to SP2010.

    I did some search on internet and found similar post on technet forum. But unfortunetly that is not useful for me. http://social.technet.microsoft.com/Forums/nl/sharepoint2010customization/thread/c385cbd4-3cdf-4143-8892-211e15292536

    can someone please suggest some solution?


    Mahesh Mitkari Cognition InfoTech

    Sunday, July 29, 2012 8:07 AM

Answers

  • I don't know exactly what is going on with this issue, but my guess is that this behavior is by design. I happened to notice that this attribute was removed from the overridden CreateChildControls method from SharePoint 2007 to SharePoint 2010.

    [SharePointPermissionAttribute(SecurityAction.Demand, ObjectModel=true)]

    See the documentation before:

    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.datetimecontrol.createchildcontrols(v=office.12).aspx

    and after:

    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.datetimecontrol.createchildcontrols.aspx

    My guess is that, if you remove the TextBox control, you are going to get the same error for the DropDownList control.

    I think your only option is going to be to rework the webpart.


    Doug Hemminger http://www.sharepointdoug.com

    • Marked as answer by Pengyu Zhao Monday, August 6, 2012 2:22 AM
    Monday, July 30, 2012 2:44 AM
  • sharing solutions which worked for me...

    I removed all Textbox controls and Dropdown controls added inside DateTimeControl and it started working fine. those textbox as well as dropdown control is no more needed and you can get those dropdown to display time by default if you set DateOnly property as false.

    following one line is sufficient to display DateTime control in 2010 and you don't need to add those child controls inside it to display time.

    <SharePoint:DateTimeControl ID="DTCFrom" runat="server" DateOnly="false" Visible="false"/>
    

     

    Mahesh Mitkari Cognition InfoTech

    • Marked as answer by Mahesh Mitkari Tuesday, August 28, 2012 11:53 AM
    Tuesday, August 28, 2012 11:52 AM

All replies

  • I don't know exactly what is going on with this issue, but my guess is that this behavior is by design. I happened to notice that this attribute was removed from the overridden CreateChildControls method from SharePoint 2007 to SharePoint 2010.

    [SharePointPermissionAttribute(SecurityAction.Demand, ObjectModel=true)]

    See the documentation before:

    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.datetimecontrol.createchildcontrols(v=office.12).aspx

    and after:

    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.datetimecontrol.createchildcontrols.aspx

    My guess is that, if you remove the TextBox control, you are going to get the same error for the DropDownList control.

    I think your only option is going to be to rework the webpart.


    Doug Hemminger http://www.sharepointdoug.com

    • Marked as answer by Pengyu Zhao Monday, August 6, 2012 2:22 AM
    Monday, July 30, 2012 2:44 AM
  • sharing solutions which worked for me...

    I removed all Textbox controls and Dropdown controls added inside DateTimeControl and it started working fine. those textbox as well as dropdown control is no more needed and you can get those dropdown to display time by default if you set DateOnly property as false.

    following one line is sufficient to display DateTime control in 2010 and you don't need to add those child controls inside it to display time.

    <SharePoint:DateTimeControl ID="DTCFrom" runat="server" DateOnly="false" Visible="false"/>
    

     

    Mahesh Mitkari Cognition InfoTech

    • Marked as answer by Mahesh Mitkari Tuesday, August 28, 2012 11:53 AM
    Tuesday, August 28, 2012 11:52 AM