|
田志鹏 能不你的问题说的更详细一点吗?
要是有DEMO附上更好了。 CS页面: using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { this.Calendar1.Attributes.Add("style", "display:none;border-width:1px;border-style:solid;border-collapse:collapse;z-index: 100; left: 0px;"); TextBox1.Attributes.Add("onfocus", "javascript:document.getElementById('Calendar1').style.display=''"); } protected void Calendar1_SelectionChanged(object sender, EventArgs e) { TextBox1.Text = this.Calendar1.SelectedDate.ToShortDateString(); Calendar1.Attributes.Add("onblur", "javascript:document.getElementById('Calendar1').style.display='none'"); } } htmld页面: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Calendar1.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>无标题页 </title> </head> <body> <form id="form1" runat="server"> <div> <asp:TextBox ID="TextBox1" runat="server"> </asp:TextBox> <asp:Calendar ID="Calendar1" runat="server" OnSelectionChanged="Calendar1_SelectionChanged"> </asp:Calendar> </div> </form> </body> </html> 就是让Textbox失去焦点时,触发相应的事件不就成了。也就是二楼所说的办了。 |