[2008] Error with DateAndTimePicker in code-behind

Frorcebrubbap

New Member
Hi all,
I used in some previous web projects a DateTimePicker control and all worked fine. Those project had the web pages without code-behind.
Now, in a new project I use the code-behind feature but, with the DateTimePicker control I have some problem:
The project run without errors but when I try to publish it the compiler returns the following error:

error BC30002: Type 'DateandTimePicker' not defined.

Can anyone help me?
Many thanks in advance.
Robert.You have to IMPORT it into your project. Possibly have to explicitly make sure it's imported into the codebehind code.Thank you for quick reply.
Consider that in a local run-time all function fine and, moreover with the previous version either in local or remote I have no error. I have not to import a component because I have completely rewritten this component. My main question is why in local does not appear that error? Why all works correctly without code-behind? How can I solve without return to the one page code?The ".aspx" page uses different syntax to specify imports than do code-behind page.

Since you don't show any code, I can't guess why this is happening. But I say again: If you use add the proper IMPORT(s) to your code-behind page, it should work.Hi Bill,
thanks you again for the attention here are the 2 pieces of code. The first works and the second expose the error:

The following code is in a one page web page and works

<%@ Page Language="VB" MasterPageFile="News.master" Culture="it-IT" UICulture="it" Title="Inserimento/ Modifica Notizia" %>
<%@ Import Namespace="System.Data" %>
<%@ Register TagPrefix="Club" Namespace="ClubSite" %>
<%@ Register TagPrefix="Club" TagName="DateandTimePicker" Src=http://aspmessageboard.com/archive/index.php/"~/DateandTimePicker.ascx" %>

<script runat="server">
… some code

Protected Sub FormView1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) '*

If FormView1.CurrentMode = FormViewMode.Insert Then
CType(FormView1.FindControl("dtpicker"), DateandTimePicker).selectedDateTime = Now

… some code
</script>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server" >
<div id="body" >
<asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource"
… some code
<tr>
<td class="formlabel">Date</td>
<td align="left">
<Club:DateandTimePicker ID="dtpicker" runat="server" />
</tr>
… some code
</asp:Content>

The following code is code behind web page and doesn’t work

<%@ Page Language="VB" MasterPageFile="~/Annunci/Annunci.master" AutoEventWireup="false" CodeFile="Annunci_Edit.aspx.vb" Inherits="Annunci_Annunci_Edit" title="Pagina senza titolo" %>
<%@ Register TagPrefix="Club" Namespace="ABCasaSite" %>
<%@ Register TagPrefix="Club" TagName="DateandTimePicker" Src=http://aspmessageboard.com/archive/index.php/"~/DateandTimePicker.ascx" %>


<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div id="body" >

<td class="formlabel">Date</td>
<td align="left">
<Club:DateandTimePicker ID="dtpicker" runat="server" selectedDateTime='<%#Bind("itemdate") %>' />
</td>
… some code


Behind-code

Imports System.Data
Imports ASP
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls

… some code

If LCase(CStr(action)) = "new" Then
FormView1.ChangeMode(FormViewMode.Insert)

This line is the error line
CType(FormView1.FindControl("dtpicker"), DateandTimePicker).selectedDateTime = Now

… Some code
Many thanks for further help and suggestions.
Robert.Ahhh...you didn't say it was your own private DataandTimePicker control!!!

You are out of my knowledge area. Somehow, you have to Import your Club.DateandTimePicker to the code-behind page, but I'm not sure what the right path, etc., for that would be.Hi Bill and thanks you again.
The control is not my own private control but is part of the ClubSite free template available from the ASP page of Microsoft.

The error exposed is :

error BC30002: Type 'DateandTimePicker' not defined.

My main problem is that I don
 
Top