I'm building a process for creating a dynamic form in ASP VB. I can easily create text boxes, drop down lists, multi select lists etc...
One thing I can't seem to do though is dynamically create a calendar control and make it "pop up" on request.
I've pulled out some code to try and isolate what the code is supposed to achieve.
Hitting the "..." button should make the calendar control visible. Only it doesn't
Heres some example code:
TIA!!!
One thing I can't seem to do though is dynamically create a calendar control and make it "pop up" on request.
I've pulled out some code to try and isolate what the code is supposed to achieve.
Hitting the "..." button should make the calendar control visible. Only it doesn't
Heres some example code:
Code:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="calendarTest.aspx.vb" Inherits="calendarTest" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> <asp:PlaceHolder ID="mycalendarPlaceholder" runat="server"></asp:PlaceHolder> <br /> <asp:Literal ID="Literal1" runat="server"></asp:Literal></div> </form> </body> </html>
Code:
Partial Class calendarTest Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim mycalendarTextbox As New TextBox() Dim mycalendarButton As New Button() Dim mycalendar As New Calendar mycalendar.ID = "calendar1" mycalendar.Visible = False mycalendarTextbox.ID = "Cal1" mycalendarTextbox.Text = CType(System.DateTime.Now, String) mycalendarButton.ID = "calendarButton" mycalendarButton.Text = "..." mycalendarButton.Attributes("OnClick") = "calendarButton_Click()" mycalendarPlaceholder.Controls.Add(mycalendarTextbox) mycalendarPlaceholder.Controls.Add(mycalendarButton) mycalendarPlaceholder.Controls.Add(mycalendar) End Sub Protected Sub calendarButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Dim mc As Calendar = CType(form1.FindControl("calendar1"), Calendar) mc.Visible = True ' mycalendarPlaceholder.Controls.Add(mc) Literal1.Text = Literal1.Text + "test1" End Sub End Class
Comment