国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

在ASP.NET中實(shí)現(xiàn)彈出日歷

2024-07-10 12:56:17
字體:
供稿:網(wǎng)友

ctlcalendar.ascx的源代碼:

<%@ control language="c#" autoeventwireup="false" codebehind="ctlcalendar.ascx.cs" inherits="calendar.ctlcalendar" targetschema="http://schemas.microsoft.com/intellisense/ie5" enableviewstate="true"%>
<asp:textbox id="textbox1" runat="server"></asp:textbox>
<input type="button" id="button1" runat="server" value="..."><br>
<asp:panel id="pnlcalendar" runat="server" >
 <asp:calendar id="calendar1" runat="server" firstdayofweek="monday" showgridlines="true" backcolor="white"
  daynameformat="full" forecolor="black" font-size="8pt" font-names="verdana" bordercolor="#999999"
  cellpadding="4" width="200px" height="180px">
  <todaydaystyle forecolor="black" backcolor="#cccccc"></todaydaystyle>
  <selectorstyle backcolor="#cccccc"></selectorstyle>
  <daystyle wrap="false" borderstyle="dashed"></daystyle>
  <nextprevstyle verticalalign="bottom"></nextprevstyle>
  <dayheaderstyle font-size="x-small" font-names="宋體" wrap="false" borderstyle="dashed" backcolor="#cccccc"></dayheaderstyle>
  <selecteddaystyle font-bold="true" forecolor="white" backcolor="#666666"></selecteddaystyle>
  <titlestyle font-size="small" font-bold="true" borderstyle="solid" bordercolor="black" backcolor="#999999"></titlestyle>
  <weekenddaystyle backcolor="lightsteelblue"></weekenddaystyle>
  <othermonthdaystyle forecolor="gray"></othermonthdaystyle>
 </asp:calendar>
</asp:panel>

ctlcalendar.ascx.cs的源代碼:

namespace calendar
{
 using system;
 using system.data;
 using system.drawing;
 using system.web;
 using system.web.ui.webcontrols;
 using system.web.ui.htmlcontrols;

 /// <summary>
 ///  ctlcalendar 的摘要說明。
 /// </summary>
 public class ctlcalendar : system.web.ui.usercontrol
 {
  protected system.web.ui.webcontrols.textbox textbox1;
  protected system.web.ui.webcontrols.panel pnlcalendar;
  protected system.web.ui.htmlcontrols.htmlinputbutton button1;
  protected system.web.ui.webcontrols.calendar calendar1;

  private void page_load(object sender, system.eventargs e)
  {
   // 在此處放置用戶代碼以初始化頁面
   if (!page.ispostback)
   {
    this.textbox1.text = system.datetime.now.toshortdatestring();
    this.pnlcalendar.attributes.add("style","display: none; position: absolute");
   }
   else
   {
    string id = page.request.form["__eventtarget"].substring(0,page.request.form["__eventtarget"].indexof(":"));
    if (id != this.id)
    {
     this.pnlcalendar.attributes.add("style","display: none; position: absolute");
    }
    else
    {
     this.pnlcalendar.attributes.add("style","position: absolute");
    }

   }

   page.registerclientscriptblock("script_panel" + this.id,
    "<script> function on"+this.id+"click() {  if("+this.id+
"_pnlcalendar.style.display == /"none/")     "+this.id+
"_pnlcalendar.style.display = /"/";   else    "+this.id+
"_pnlcalendar.style.display = /"none/"; } </script>");   
   this.button1.attributes.add("onclick","on"+this.id+"click()");
   
  }


  #region web 窗體設(shè)計(jì)器生成的代碼
  override protected void oninit(eventargs e)
  {
   //
   // codegen: 該調(diào)用是 asp.net web 窗體設(shè)計(jì)器所必需的。
   //
   initializecomponent();
   base.oninit(e);
  }
  
  /// <summary>
  ///  設(shè)計(jì)器支持所需的方法 - 不要使用代碼編輯器
  ///  修改此方法的內(nèi)容。
  /// </summary>
  private void initializecomponent()
  {
   this.calendar1.selectionchanged += new system.eventhandler(this.calendar1_selectionchanged);
   this.load += new system.eventhandler(this.page_load);

  }
  #endregion

  #region 日歷選擇時的事件
  private void calendar1_selectionchanged(object sender, system.eventargs e)
  {
   this.textbox1.text = calendar1.selecteddate.toshortdatestring();
   this.pnlcalendar.attributes.add("style","display: none; position: absolute");
  }
  #endregion
 }
}








商業(yè)源碼熱門下載www.html.org.cn

發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 丽水市| 舒兰市| 秦皇岛市| 大宁县| 阳高县| 隆化县| 九江县| 原阳县| 龙州县| 德阳市| 静乐县| 清水县| 尼木县| 锦屏县| 黑水县| 江华| 皋兰县| 海原县| 海门市| 修武县| 澜沧| 顺平县| 伊金霍洛旗| 大化| 辽阳县| 饶阳县| 益阳市| 虎林市| 恭城| 台江县| 漳浦县| 石家庄市| 融水| 南岸区| 侯马市| 安顺市| 保亭| 宁都县| 贵港市| 张北县| 广安市|