hola a todos esperando que todos podamos resolver este problema.. lo que pasa es que tengo un calendario el cual tiene dos dropdownlist para seleccionar el mes y el año, pero es logico que de los meses que ya pasaron y los dias que tambien pasaron no se puedan seleccionar y bueno ya he logrado que los meses y sus dias anteriores aparescan deshabilitados , tambien ya logre que si escoges un mes y una año mayor del 2004 aparescan habilitados los dias de los meses.. pero lo que no logro hacer es de qe en el mes en el que estamos los dias anteriores al dia de hoy aparescan deshablitados le he movido de muchas formas, pero siempre me dan caminos diferentes .. originalmente este es un codigo que hace eso
Private Sub Calendar1_DayRender (ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) Handles Calendar1.DayRender
If (e.Day.Date.Day < Now.Day) Or (e.Day.Date.Month < Now.Month) Then
e.Day.IsSelectable = False
End If
End Sub
este codigo ahce lo que quiero, pero si te vas a meses anteriores te deshabilita los dias que ya pasaron pero conforme a la fecha de hoy osea que si hoy es 18 de octubre, y te vas a septiemble , en este mes te deshabilitara del 1 al 17 pero del 18 al 30 de semtiembre aparecera hablitado, pero en agosto apareceren habilitados los diasd del 18 al 31 y asi en cada mes, osea no cumple regla...
en este codigo ...
Sub DayRender(source As Object, e As DayRenderEventArgs)
If (e.Day.Date.Month < Now.Month) or (e.Day.Date.Year < Now.Year) Then
e.Day.IsSelectable = False
End If
if (e.Day.Date.Year > Now.Year)
e.Day.IsSelectable = True
End If
End Sub
si cumple que los dias anteriores de meses anteriores aparescan deshabilitados, pero en el mes actual aparecen todos los dias habilitados.. si alguien me puede ayudar para que el mes actual no me selecione los dias anteriores a hoy, se los agradeceria porque he hecho todas las convinaciones posibles y no me sale y seefectan todos los meses anteriores o los meses que de años que aun no llegan....
aqui esta todo el codigo pero la perte que en verdad debe de ser..
Código:
<%@ Page Language="VB" Debug="true"%>
<%@ import Namespace="System.Globalization" %>
<script runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
myCalendar.ShowTitle = False
If Not Page.IsPostBack Then
response.Write(Request.QueryString("textbox"))
Call Populate_MonthList()
Call Populate_YearList()
End If
End Sub
Sub Calendar1_DayRender(Sender As Object, E As EventArgs)
'document.forms[0].elements[obj]
'
System.Threading.Thread.CurrentThread.CurrentCulture = New System.Globalization.CultureInfo("en-US")
If Not Request.QueryString("textbox") Is Nothing Then
Dim strScript As String = "<script>window.opener.document.forms(0)." + Request.QueryString("textbox").ToString + ".value = '"
strScript += myCalendar.SelectedDate.ToShortDateString()
strScript += "';self.close()"
strScript += "</" + "script>"
RegisterClientScriptBlock("Calendar_ChangeDate", strScript)
End If
' Calen.Text = myCalendar.SelectedDate.ToShortDateString()
End sub
Sub DayRender(source As Object, e As DayRenderEventArgs)
If (e.Day.Date.Month < Now.Month) or (e.Day.Date.Year < Now.Year) Then
e.Day.IsSelectable = False
End If
if (e.Day.Date.Year > Now.Year)
e.Day.IsSelectable = True
End If
End Sub
Sub Set_Calendar(Sender As Object, E As EventArgs)
'Whenever month or year selection changes display the calendar for that month/year
myCalendar.TodaysDate = CDate(drpCalMonth.SelectedItem.Value & " 1, " & drpCalYear.SelectedItem.Value)
End Sub
Sub Populate_MonthList()
drpCalMonth.Items.Add("January")
drpCalMonth.Items.Add("February")
drpCalMonth.Items.Add("March")
drpCalMonth.Items.Add("April")
drpCalMonth.Items.Add("May")
drpCalMonth.Items.Add("June")
drpCalMonth.Items.Add("July")
drpCalMonth.Items.Add("August")
drpCalMonth.Items.Add("September")
drpCalMonth.Items.Add("October")
drpCalMonth.Items.Add("November")
drpCalMonth.Items.Add("December")
drpCalMonth.Items.FindByValue(MonthName(DateTime.Now.Month)).Selected = True
End Sub
Sub Populate_YearList()
Dim intYear As Integer
For intYear = DateTime.Now.Year to DateTime.Now.Year + 10
drpCalYear.Items.Add(intYear)
Next
drpCalYear.Items.FindByValue(DateTime.Now.Year).Selected = True
End Sub
function MonthName (intMonth)
select case intMonth
case 1
MonthName = "January"
case 2
MonthName = "February"
case 3
MonthName = "March"
case 4
MonthName = "April"
case 5
MonthName = "May"
case 6
MonthName = "June"
case 7
MonthName = "July"
case 8
MonthName = "August"
case 9
MonthName = "September"
case 10
MonthName = "October"
case 11
MonthName = "November"
case 12
MonthName = "December"
end select
end function
</script>
<style type="text/css">
BODY { font-family: verdana, arial, helvetica;
}
.calTitle {font-weight: bold;
font-size: 11;
background-color:#cccccc;
color: black;
width: 90px;
}
.calBody {font-size: 11;
border-width: 10px;
}
</style>
<table cellspacing="0" cellpadding="0" width="20%" border="0">
<form id="frmCal" runat="server">
<tbody>
<tr>
<td align="left" bgcolor="#cccccc">
<asp:DropDownList id="drpCalMonth" Runat="Server" AutoPostBack="True" OnSelectedIndexChanged="Set_Calendar" cssClass="calTitle"></asp:DropDownList>
</td>
<td align="right" bgcolor="#cccccc">
<asp:DropDownList id="drpCalYear" Runat="Server" AutoPostBack="True" OnSelectedIndexChanged="Set_Calendar" cssClass="calTitle"></asp:DropDownList>
</td>
</tr>
<tr>
<td colspan="2">
<asp:Calendar OnSelectionChanged="Calendar1_DayRender" OnDayRender="DayRender" OtherMonthDayStyle-BackColor="White" DayStyle-BackColor="LightYellow" id="myCalendar" Runat="Server" cssClass="calBody" DayHeaderStyle-BackColor="#eeeeee" Width="100%"></asp:Calendar>
<asp:label ID="calen" runat="server"></asp:label>
</td>
</tr>
</tbody>
</form>
</table>