新手弱问:如何在页面上实现 探出的选择日期效果呢?
RT
------解决方案--------------------给你两个例子:
第一个:
<table cellpadding= "0 " cellspacing= "0 ">
<tr>
<td>
<asp:TextBox ID= "TextBox1 " runat= "server "> </asp:TextBox> </td>
</tr>
<tr>
<td style= "height: 19px ">
<asp:Calendar ID= "Calendar1 " runat= "server " OnSelectionChanged= "Calendar1_SelectionChanged ">
</asp:Calendar>
</td>
</tr>
</table>
protected void Page_Load(object sender, EventArgs e)
{
this.TextBox1.Attributes[ "onclick "] = "var x= " + this.Calendar1.ClientID +
";x.style.display=x.style.display== 'inline '? 'none ': 'inline '; ";
this.Calendar1.Style[ "position "] = "absolute ";
this.Calendar1.Style[ "display "] = "none ";
}
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
this.TextBox1.Text = this.Calendar1.SelectedDate.Date.ToString( "D ");
}
例子二:
<table cellpadding= "0 " cellspacing= "0 ">
<tr>
<td>
<asp:TextBox ID= "TextBox1 " runat= "server "> </asp:TextBox> </td>
</tr>
<tr>
<td style= "height: 19px ">
<asp:Calendar ID= "Calendar1 " runat= "server " OnSelectionChanged= "Calendar1_SelectionChanged "
OnVisibleMonthChanged= "Calendar1_VisibleMonthChanged "> </asp:Calendar>
</td>
</tr>
</table>
public partial class _Default : System.Web.UI.Page,IPostBackEventHandler
{
protected void Page_Load(object sender, EventArgs e)
{
this.TextBox1.Attributes[ "onclick "] = this.ClientScript.GetPostBackEventReference(this, " ");
this.Calendar1.Style[ "position "] = "absolute ";
if (!IsPostBack)
this.Calendar1.Visible = false;
}
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
this.TextBox1.Text = this.Calendar1.SelectedDate.Date.ToString( "D ");
this.Calendar1.Visible = false;
}
protected void Calendar1_VisibleMonthChanged(object sender, MonthChangedEventArgs e)
{
this.Calendar1.VisibleDate = e.NewDate;
}
#region IPostBackEventHandler 成员
public void RaisePostBackEvent(string eventArgument)
{
this.Calendar1.Visible = true;
}
#endregion
}