ID not recognized in .ascx page
- by Alexander
I have the following code:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="DurationPicker.ascx.cs" Inherits="Permias.DurationPicker" %>
<%@ Register TagPrefix="Club" Namespace="ClubSite" %>
<div class="controlblock">
<table>
<tr>
<td>
Start Date:
</td>
<td>
<Club:DatePicker ID="dp1" runat="server" />
</td>
<td>
<Club:TimePicker ID="tp1" runat="server" />
</td>
</tr>
<tr>
<td>
End Date:
</td>
<td>
<Club:DatePicker ID="dp2" runat="server" />
</td>
<td>
<Club:TimePicker ID="tp2" runat="server" />
</td>
</tr>
</table>
</div>
In my code behind I have
public System.DateTime startDateTime
{
get
{
return dp1.SelectedDate.Add(tp1.SelectedTime.TimeOfDay);
}
set
{
dp1.SelectedDate = value;
tp1.SelectedTime = value;
}
}
However dp1 is underlined in red, which means it can't find dp1.. why is this?