SharePoint - DateTimeControl does not exist in the namespace?
-
08-10-2020 - |
Domanda
I am getting the following error:
The type or namespace name DateTimeControl does not exist in the namespace Microsoft.SharePoint.WebControls (are you missing an assembly reference?)
**VIEW**
<tr>
<td class="auto-style1">StartDate <span class="ms-error">*</span></td>
<td>
<spuc:DateTimeControl ID="dtStartdate" runat="server" DateOnly="true" />
</td>
</tr>
**C#**
itemToAdd["StartDate"] = dtStartdate.SelectedDate;
What could be the issue?
Soluzione
If your solution is sandbox solution then "DateTimeControl" will not support. Because "DateTimeControl" is exist in "Microsoft.SharePoint.WebControls" namespace. And According to microsoft, All of the control classes in the Microsoft.SharePoint.WebControls namespace is not supported in sandbox solution.
You have two options for make it work,
Use sandbox proxy within your sandbox solution. (Sandbox proxies are components that enable you to make full-trust functionality available to sandboxed solutions)
OR
Make it farm solution by setting the project's "Sandboxed Solution" property to false.
click on "test" and press F4. it will open property window. there is property named "sandbox solution". set this to false.