Click here to Skip to main content
15,884,836 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am working on clendar, in this I have calendar dayrender event is there.

in dayrender event I am assign textbox1.Text="test"; but it is not visible after completing dayrender event?

my code is

<table>
                   <tr>
                       <td>
                       </td>
                       <td>
                           <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                       </td>
                   </tr>
                   <tr>
                       <td>
                       </td>
                       <td>
                           <asp:Calendar ID="AttenCalendar" runat="server" BackColor="White" BorderColor="SteelBlue"
                               BorderWidth="1px" Font-Names="Verdana" Font-Size="9pt" ForeColor="Black" Height="275px"
                               Width="100%" FirstDayOfWeek="Sunday" NextMonthText="Next >" PrevMonthText="< Prev"
                               NextPrevFormat="ShortMonth" ShowGridLines="false" BorderStyle="None" CssClass="monthCalendar"
                               OnDayRender="AttenCalendar_DayRender" SelectionMode="None" DayNameFormat="FirstLetter"
                               OtherMonthDayStyle-CssClass="otherMonthStyle" DayStyle-CssClass="dayStyle" DayHeaderStyle-CssClass="dayHeaderStyle"
                               WeekendDayStyle-CssClass="weekendDayStyle" TodayDayStyle-CssClass="todayStyle"
                               TitleStyle-CssClass="weekendDayStyle">
                               <%-- <TitleStyle BorderColor="SteelBlue" BorderWidth="1px" Font-Bold="True" Font-Size="10pt"
                                           Height="40px" BackColor="White" ForeColor="Black" HorizontalAlign="Center" VerticalAlign="Middle" />--%>
                           </asp:Calendar>
                       </td>
                   </tr>
               </table>


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Default3 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void AttenCalendar_DayRender(object sender, DayRenderEventArgs e)
    {
        TextBox1.Text = "hi";
    }
}


may I know what's wrong in this?

Thanks in advance........
Posted

1 solution

It might be a bug. After little rnd i found that when I move your TextBox1 from above of the AttenCalendar control to bellow, then value is assigned and displayed.
when I use the bellow code
XML
<div>
        <asp:TextBox ID="txtId" runat="server"></asp:TextBox>
    </div>
    <div>
        <asp:Calendar ID="AttenCalendar" runat="server" BackColor="White" BorderColor="SteelBlue"
                                BorderWidth="1px" Font-Names="Verdana" Font-Size="9pt" ForeColor="Black" Height="275px"
                                Width="100%" FirstDayOfWeek="Sunday" NextMonthText="Next >" PrevMonthText="< Prev"
                                NextPrevFormat="ShortMonth" ShowGridLines="false" BorderStyle="None" CssClass="monthCalendar"
                                OnDayRender="AttenCalendar_DayRender" SelectionMode="None" DayNameFormat="FirstLetter"
                                OtherMonthDayStyle-CssClass="otherMonthStyle" DayStyle-CssClass="dayStyle" DayHeaderStyle-CssClass="dayHeaderStyle"
                                WeekendDayStyle-CssClass="weekendDayStyle" TodayDayStyle-CssClass="todayStyle"
                                TitleStyle-CssClass="weekendDayStyle">
      </asp:Calendar>
    </div>


The textbox value is not assigned/displayed by DayRender event handler.
C#
protected void AttenCalendar_DayRender(object sender, DayRenderEventArgs e)
       {
           txtId.Text ="hi";
       }


But same thing is assigned when my markup like as follows(just textbox1 is bellow of Calender control)
XML
<div>
        <asp:Calendar ID="AttenCalendar" runat="server" BackColor="White" BorderColor="SteelBlue"
                                BorderWidth="1px" Font-Names="Verdana" Font-Size="9pt" ForeColor="Black" Height="275px"
                                Width="100%" FirstDayOfWeek="Sunday" NextMonthText="Next >" PrevMonthText="< Prev"
                                NextPrevFormat="ShortMonth" ShowGridLines="false" BorderStyle="None" CssClass="monthCalendar"
                                OnDayRender="AttenCalendar_DayRender" SelectionMode="None" DayNameFormat="FirstLetter"
                                OtherMonthDayStyle-CssClass="otherMonthStyle" DayStyle-CssClass="dayStyle" DayHeaderStyle-CssClass="dayHeaderStyle"
                                WeekendDayStyle-CssClass="weekendDayStyle" TodayDayStyle-CssClass="todayStyle"
                                TitleStyle-CssClass="weekendDayStyle">
      </asp:Calendar>
    </div>
     <div>
        <asp:TextBox ID="txtId" runat="server"></asp:TextBox>
    </div>

It is assigned and displayed to my page.
 
Share this answer
 
Comments
Bojjaiah 18-Feb-13 5:29am    
Hi Habib,
:) 5+.

Thanks for reply.
Now it's working fine. why it act's like this.
Actually in my diesign requirement the textbox value shows above of the Calendar.
So, If I shows the textbox value in above of the Calendar what should I do?
S. M. Ahasan Habib 18-Feb-13 6:33am    
Then you need to assign that controls value with other events like OnInit,OnLoad,OnPreRender etc, not inside DayRender event.
Bojjaiah 18-Feb-13 8:24am    
your telling Page events or control events? even thought I tried both Page and Control level events? but it's not working when textbox is above the calendar control.
S. M. Ahasan Habib 18-Feb-13 10:12am    
I checked it by assigning txtId.Text ="hi" from form load events and found it is working.
Bojjaiah 19-Feb-13 1:19am    
As per my requirements I am calculated the sum of value in dayrendar event, So, I need to add sum of value after dayrender event completed? So, In postback event I can't assign sum of value after dayrender event completed?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900