[待解决问题] 如何让日历控件输入相应的日期TextBox响应事件?
提问时间: 2008-05-09 08:30
离问题结束还有 10 天 19 小时 浏览:65 次
如何让日历控件输入相应的日期TextBox响应事件?我实验了,如果手动在textbox里面输入日期就能生成回传,但是如果靠js就生成不了事件,请求援助
提问者:田志鹏 - 初学一级
所有回答(3)
田志鹏  能不你的问题说的更详细一点吗?
要是有DEMO附上更好了。
4天前   回答者:金鱼 - 初学一级
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>
4天前   回答者:小孤狸 - 初学一级
就是让Textbox失去焦点时,触发相应的事件不就成了。也就是二楼所说的办了。
3天前   回答者:JackLee - 菜鸟二级
   您需要登录以后才能回答!
我的问题    我要提问


快到期问题

> 问题排行榜

有不合适内容,建议去除