G
Guest
Try to put in a TextBox next month's date in format (MMM yyyy). The following
does NOT work, why is that?
<!--When rendered, the texbox is blank, although the text in the round
bracket after the textbox is rendered correctly as (July, 2005)-->
<asp:TextBox id="MonthTextBox"
runat="server"><%=System.DateTime.Now.ToString("y")%></asp:TextBox>
(<%=System.DateTime.Now.ToString("y")%>)
<!--Same again. defaultMonth is initialised as early as page_init (as
opposed to page_load makes no difference
the text in round bracket after the textbox is displayed correctly-->
<asp:TextBox id="MonthTextBox"
runat="server"><%=defaultMonth%></asp:TextBox> (<%=defaultMonth%>)
//OnInit method appended here for reference
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
DateTime nextMonth = System.DateTime.Now;
nextMonth = nextMonth.AddMonths(1);
// Put user code to initialize the page here
//defaultMonth = nextMonth.ToString("y");
defaultMonth= "abc";
InitializeComponent();
base.OnInit(e);
}
However, I can do:
<asp:TextBox id="MonthTextBox" runat="server">at least this
works</asp:TextBox> (<%=defaultMonth%>)
What is going on? Using ASP.NET 1.1 on IIS5.1/WinXP Pro SP1.
does NOT work, why is that?
<!--When rendered, the texbox is blank, although the text in the round
bracket after the textbox is rendered correctly as (July, 2005)-->
<asp:TextBox id="MonthTextBox"
runat="server"><%=System.DateTime.Now.ToString("y")%></asp:TextBox>
(<%=System.DateTime.Now.ToString("y")%>)
<!--Same again. defaultMonth is initialised as early as page_init (as
opposed to page_load makes no difference
the text in round bracket after the textbox is displayed correctly-->
<asp:TextBox id="MonthTextBox"
runat="server"><%=defaultMonth%></asp:TextBox> (<%=defaultMonth%>)
//OnInit method appended here for reference
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
DateTime nextMonth = System.DateTime.Now;
nextMonth = nextMonth.AddMonths(1);
// Put user code to initialize the page here
//defaultMonth = nextMonth.ToString("y");
defaultMonth= "abc";
InitializeComponent();
base.OnInit(e);
}
However, I can do:
<asp:TextBox id="MonthTextBox" runat="server">at least this
works</asp:TextBox> (<%=defaultMonth%>)
What is going on? Using ASP.NET 1.1 on IIS5.1/WinXP Pro SP1.