Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET C#4.0
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 17-Feb-13 21:18pm
Bojjaiah6.1K

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
<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.
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)
<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.
  Permalink  
Comments
Bojjaiah at 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 at 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 at 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 at 18-Feb-13 10:12am
   
I checked it by assigning txtId.Text ="hi" from form load events and found it is working.
Bojjaiah at 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
0 DamithSL 325
1 Maciej Los 217
2 OriginalGriff 213
3 BillWoodruff 79
4 Jose Garcia Sevilla 75
0 OriginalGriff 7,953
1 DamithSL 6,139
2 Sergey Alexandrovich Kryukov 5,454
3 Maciej Los 5,293
4 Kornfeld Eliyahu Peter 4,539


Advertise | Privacy | Mobile
Web02 | 2.8.141223.1 | Last Updated 18 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100