We help IT Professionals succeed at work.

Float days (numbers) left in vb.net calendar

Is there away so you can float the number to the left in the vb.net calendar

 <asp:Calendar ID="Calendar1" runat="server" BackColor="#2677B4" 
        BorderColor="Black" BorderStyle="Solid" CellSpacing="1" Font-Names="Verdana" 
        Font-Size="8pt" ForeColor="Black" Height="299px" NextPrevFormat="ShortMonth" 
        Width="90%">
        <DayHeaderStyle Font-Bold="True" Font-Size="8pt" ForeColor="white" 
            Height="5pt" />
        <DayStyle BackColor="white" />
        <NextPrevStyle Font-Bold="True" Font-Size="8pt" ForeColor="White" />
        <OtherMonthDayStyle ForeColor="#999999" />
        <SelectedDayStyle BackColor="white" ForeColor="black" />
        <TitleStyle  CssClass="calborder" BackColor="#1f4b83" BorderStyle="None" Font-Bold="True" 
            Font-Size="12pt" ForeColor="White" Height="12pt" />
        <TodayDayStyle BackColor="white" ForeColor="red" />
         </asp:Calendar>

Open in new window

Comment
Watch Question

Ramkisan JagtapLead Developer

Commented:
please check following link
Http://forums.asp.net/t/1486763.aspx/1
CERTIFIED EXPERT
Top Expert 2015

Commented:
This is all you need:

Protected Sub Calendar1_DayRender(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) Handles Calendar1.DayRender
        e.Cell.Style.Item("text-align") = "left"
    End Sub

Author

Commented:
Hello tommyboy...

Is there anyway to remove the space to the right of the number ...

in the image below i have highlighted the space and shown what i would like it 2 look like in the 1/11/2011
Image1.jpg
CERTIFIED EXPERT
Top Expert 2015

Commented:
Probably. How are you adding the images to the calendar days?

Author

Commented:
in the code behind

 Protected Sub Calendar1_DayRender(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) Handles Calendar1.DayRender
        '##############################################
        '# Create the buttons within the calend       #
        '# set them out with spaces and panels        #
        '##############################################
        e.Cell.Style.Item("text-align") = "left"

        Dim holder As New System.Web.UI.WebControls.Panel
        holder.CssClass = "fltright2"

        Dim full As New HyperLink
        full.ImageUrl = "Images/Green_buttonlarge.jpg"
        full.NavigateUrl = Page.ClientScript.GetPostBackClientHyperlink(CalendarLinkButton, "full|" & e.Day.Date, True)
        full.CssClass = "calbtn"

        Dim am As New HyperLink

        am.ImageUrl = "Images/Green_buttonam.jpg"
        am.NavigateUrl = Page.ClientScript.GetPostBackClientHyperlink(CalendarLinkButton, "Am|" & e.Day.Date, True)
        am.CssClass = "calbtn"

        Dim pm As New HyperLink
        pm.ImageUrl = "Images/Green_buttonpm.jpg"
        pm.NavigateUrl = Page.ClientScript.GetPostBackClientHyperlink(CalendarLinkButton, "Pm|" & e.Day.Date, True)
        pm.CssClass = "calbtn"

        holder.Controls.Add(full)

        Dim spacer As New System.Web.UI.WebControls.Label
        spacer.Text = "<br />"
        holder.Controls.Add(spacer)
        holder.Controls.Add(am)
        holder.Controls.Add(pm)

      e.Cell.Controls.Add(holder)

Open in new window





css is:
  
.fltleft
{
    float:left;
    clear:both;
}
  .fltright2
        {
            float: right;
            clear: both;
                   
                   }

Open in new window

CERTIFIED EXPERT
Top Expert 2015

Commented:
What does css "calbtn" look like?
CERTIFIED EXPERT
Top Expert 2015

Commented:
Actually, never mind the calbtn css, just add this:

        e.Cell.Style.Item("text-align") = "left"
        e.Cell.Style.Item("vertical-align") = "top"

        Dim holder As New System.Web.UI.WebControls.Panel
        holder.CssClass = "fltright2"

        Dim full As New HyperLink
     
        .....
       
        ......

Author

Commented:
that didnt alter anything sadly
CERTIFIED EXPERT
Top Expert 2015
Commented:
Here's my copy of your DayRender event and a partial screen shot of the results. Naturally I don't have your images, so I used my own and I commented out the NavigationUrls. The only thing missing on my end is the calbtn css class.
Protected Sub Calendar1_DayRender(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) Handles Calendar1.DayRender
        e.Cell.Style.Item("text-align") = "left"
        e.Cell.Style.Item("vertical-align") = "top"

        Dim holder As New System.Web.UI.WebControls.Panel
        holder.CssClass = "fltright2"

        Dim full As New HyperLink
        full.ImageUrl = "images/red.jpg"
        'full.NavigateUrl = Page.ClientScript.GetPostBackClientHyperlink(CalendarLinkButton, "full|" & e.Day.Date, True)
        full.CssClass = "calbtn"

        Dim am As New HyperLink

        am.ImageUrl = "images/green.jpg"
        'am.NavigateUrl = Page.ClientScript.GetPostBackClientHyperlink(CalendarLinkButton, "Am|" & e.Day.Date, True)
        am.CssClass = "calbtn"

        Dim pm As New HyperLink
        pm.ImageUrl = "Images/gray.jpg"
        'pm.NavigateUrl = Page.ClientScript.GetPostBackClientHyperlink(CalendarLinkButton, "Pm|" & e.Day.Date, True)
        pm.CssClass = "calbtn"

        holder.Controls.Add(full)

        Dim spacer As New System.Web.UI.WebControls.Label
        spacer.Text = "<br />"
        holder.Controls.Add(spacer)
        holder.Controls.Add(am)
        holder.Controls.Add(pm)

        e.Cell.Controls.Add(holder)
    End Sub

Open in new window

calendar.jpg

Explore More ContentExplore courses, solutions, and other research materials related to this topic.