日期:2014-05-18  浏览次数:20432 次

大家帮忙看看哦,,,,这段VB语句怎么换成CS的,马上结贴,在线等哈
Private   Sub   Calendar1_SelectionChanged(ByVal   sender   As   System.Object,   _
    ByVal   e   As   System.EventArgs)   Handles   Calendar1.SelectionChanged

    TextBox1.Text   =   Calendar1.SelectedDate.ToShortDateString()
    Dim   div   As   System.Web.UI.Control   =   Page.FindControl( "divCalendar ")

    If   TypeOf   div   Is   HtmlGenericControl   Then
        CType(div,   HtmlGenericControl).Style.Add( "display ",   "none ")
    End   If
End   Sub




------解决方案--------------------
private void Calendar1_SelectionChanged(object sender, EventArgs e)
{
TextBox1.Text = Calendar1.SelectedDate.ToShortDateString();
System.Web.UI.Control div = Page.FindControl( "divCalendar ");
if(div is HtmlGenericControl)
{
((HtmlGenericControl)div).Style.Add( "display ", "none ");
}
}
------解决方案--------------------
不过这样写可能效率更高

private void Calendar1_SelectionChanged(object sender, EventArgs e)
{
TextBox1.Text = Calendar1.SelectedDate.ToShortDateString();
HtmlGenericControl div = Page.FindControl( "divCalendar ") as HtmlGenericControl;
if(div != null)
{
div.Style.Add( "display ", "none ");
}
}