got a question...


Lets say I have a user control for a calendar here is the html:

Code:
<%@ Control Language="vb" AutoEventWireup="false" Codebehind="CalendarControl.ascx.vb" Inherits="ims.jakah.com.CalendarControl" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<asp:textbox id="txtIssueClosed" Width="64px" runat="server"></asp:textbox>
<INPUT style="BACKGROUND-POSITION-X: center; BACKGROUND-IMAGE: url(../images/calendar.gif); WIDTH: 24px; BACKGROUND-REPEAT: no-repeat; FONT-FAMILY: Arial, SansSerif, Verdana; HEIGHT: 24px"
 onclick="OnClick()" value="..." type="button">
<br>
<div id="divCalendar" style="DISPLAY: none; POSITION: absolute"><asp:calendar id="Calendar1" Width="200px" runat="server" CellPadding="4" BorderStyle="Outset"
  BorderColor="#C7D6E4" Font-Names="Arial" Font-Size="8pt" Height="180px" ForeColor="Black" BackColor="White" BorderWidth="2px">
  <TodayDayStyle ForeColor="Black" BackColor="#CCCCCC"></TodayDayStyle>
  <SelectorStyle BackColor="#CCCCCC"></SelectorStyle>
  <NextPrevStyle VerticalAlign="Bottom"></NextPrevStyle>
  <DayHeaderStyle Font-Size="7pt" Font-Bold="True" BackColor="#CCCCCC"></DayHeaderStyle>
  <SelectedDayStyle Font-Bold="True" ForeColor="White" BackColor="#666666"></SelectedDayStyle>
  <TitleStyle Font-Bold="True" BorderColor="Black" BackColor="#999999"></TitleStyle>
  <WeekendDayStyle BackColor="#FFFFCC"></WeekendDayStyle>
  <OtherMonthDayStyle ForeColor="Gray"></OtherMonthDayStyle>
 </asp:calendar></div>
<script>
function OnClick()
{
  if( divCalendar.style.display == "none")
    divCalendar.style.display = "";
  else
    divCalendar.style.display = "none";
}
</script>
The code behind is:

VB Code:
  1. Public Class CalendarControl
  2.  
  3. Inherits System.Web.UI.UserControl
  4.  
  5. #Region " Web Form Designer Generated Code "
  6.  
  7. 'This call is required by the Web Form Designer.
  8.  
  9. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
  10.  
  11. End Sub
  12.  
  13. Protected WithEvents Calendar1 As System.Web.UI.WebControls.Calendar
  14.  
  15. Protected WithEvents txtClosed As System.Web.UI.WebControls.TextBox
  16.  
  17. Protected WithEvents txtIssueClosed As System.Web.UI.WebControls.TextBox
  18.  
  19. 'NOTE: The following placeholder declaration is required by the Web Form Designer.
  20.  
  21. 'Do not delete or move it.
  22.  
  23. Private designerPlaceholderDeclaration As System.Object
  24.  
  25. Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
  26.  
  27. 'CODEGEN: This method call is required by the Web Form Designer
  28.  
  29. 'Do not modify it using the code editor.
  30.  
  31. InitializeComponent()
  32.  
  33. End Sub
  34.  
  35. #End Region
  36.  
  37. Private Sub Calendar1_SelectionChanged(ByVal sender As System.Object, _
  38.  
  39. ByVal e As System.EventArgs) Handles Calendar1.SelectionChanged
  40.  
  41. txtIssueClosed.Text = Format(Calendar1.SelectedDate, "dd-MMM-yy")
  42.  
  43. Dim div As System.Web.UI.Control = Page.FindControl("divCalendar")
  44.  
  45. If TypeOf div Is HtmlGenericControl Then
  46.  
  47. CType(div, HtmlGenericControl).Style.Add("display", "none")
  48.  
  49. End If
  50.  
  51. End Sub
  52.  
  53. Public Function GetClosedDate() As Date
  54.  
  55. GetClosedDate = txtIssueClosed.Text
  56.  
  57. End Function
  58.  
  59. Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  60.  
  61. 'Put user code to initialize the page here
  62.  
  63. End Sub
  64.  
  65. End Class


I want to use this Calendar Control on another aspx page. So I dragged and dropped it in an ASPX file.

Now what I do is I can click the button the calendar appears I select a date and it sets that text box (txtIssueClosed). Now on this aspx I click save to save the record into a SQL db row (table). The problem is I cannot retreive txtIssueClosed no matter what I try. I had tried to declare Protected CalendarControl as CalendarControl under the inherits section of this "logissue.aspx" page but that doesnt work. I even created a function to grab the date back in the code behind of this CalendarControl.ascx file. You see it posted as GetClosedDate...but it always returns null. I tried everything but cannot get the date from this text box to be passed in my code...

If i try

CalendarControl.GetClosedDate this always returns nothing


Please help!
Thanks,

Jon