zoukankan      html  css  js  c++  java
  • confirm()对话框在.net的button中的使用,下拉日期Calendar的使用

    1,confirm()在.net的button中的使用。
        (1)对System.Web.UI.WebControls.Button button3控件
            因为它的click事件是服务器端的,首先在服务器端给button绑上客户端的事件,代码是:
            this.Button3.Attributes.Add("onclick","return confirm('aa')");
            如此即可
        (2)对protected Infragistics.WebUI.WebDataInput.WebImageButton WebImageButton2;
            需要在客户端给click事件加上WebImageButton2_Click方法,该方法代码:
            function WebImageButton2_Click(oButton, oEvent)
            { //Add code to handle your event here. 
                if(!confirm("dddd")) 
                    oEvent.needPostBack=false;
                else
                     oEvent.needPostBack=true; 
            } 
    2,对该protected Infragistics.WebUI.WebDataInput.WebDateTimeEdit idteDateTime;  控件的使用
            效果就是在单击右侧按钮后,出现protected Infragistics.WebUI.WebSchedule.WebCalendar SharedCalendar;控件,即下拉的时间表;这主要是客户端的代码,如下:
            //建立一个protected Infragistics.WebUI.WebDataInput.WebDateTimeEdit idteDateTime; 控件
             <igtxt:webdatetimeedit id="idteDateTime" runat="server" EditModeFormat="D" DisplayModeFormat="D" Width="128px" Fields="2005-7-14-0-0-0-0">
    <ButtonsAppearance CustomButtonDisplay="OnRight"></ButtonsAppearance>
    <SpinButtons Display="OnRight"></SpinButtons></igtxt:webdatetimeedit>
            //建立一个protected Infragistics.WebUI.WebSchedule.WebCalendar SharedCalendar;控件 
            <igsch1:webcalendar id="SharedCalendar" style="DISPLAY: none; Z-INDEX: 101; LEFT: 456px; POSITION: absolute; TOP: 720px"  runat="server" Width="274px" Height="196px">
    <Layout FooterFormat="Today: {0:d}" PrevMonthImageUrl="ig_cal_blueP0.gif" showtitle="false"
      NextMonthImageUrl="ig_cal_blueN0.gif">
    <FooterStyle Height="16pt" Font-Size="8pt" ForeColor="#505080" BackgroundImage="ig_cal_blue1.gif">
     <BorderDetails ColorTop="LightSteelBlue" WidthTop="1px" StyleTop="Solid"></BorderDetails> </FooterStyle>
    <SelectedDayStyle BackColor="SteelBlue"></SelectedDayStyle>
    <OtherMonthDayStyle ForeColor="SlateGray"></OtherMonthDayStyle>
    <NextPrevStyle BackgroundImage="ig_cal_blue2.gif"></NextPrevStyle>
    <CalendarStyle BorderWidth="1px" Font-Size="9pt" Font-Names="Verdana" BorderColor="SteelBlue" BorderStyle="Solid"  BackColor="#CCDDFF"></CalendarStyle>
    <TodayDayStyle BackColor="#E0EEFF"></TodayDayStyle>
     <DayHeaderStyle Height="1pt" Font-Size="8pt" Font-Bold="True" ForeColor="#8080A0" BackColor="#E0EEFF">
     <BorderDetails StyleBottom="Solid" ColorBottom="LightSteelBlue" WidthBottom="1px"></BorderDetails>
    </DayHeaderStyle>
    <TitleStyle Height="18pt" Font-Size="10pt" Font-Bold="True" ForeColor="#505080" BackgroundImage="ig_cal_blue2.gif"
     BackColor="#CCDDFF"></TitleStyle>
    </Layout>
    </igsch1:webcalendar>
            //调用 javascript 语句
            <SCRIPT>
      ig_initDropCalendar("SharedCalendar idteDateTime");
      
      // This file allows to link drop-down WebCalendar with WebDateTimeEdit
    //
    // reference to drop-down calendar
    var ig_calToDrop;
    // reference to transparent iframe used to get around bugs in IE related to <select>
    var ig_frameUnderCal;
    // event fired by WebDateTimeEdit on CustomButton
    function ig_openCalEvent(oEdit)
    {
     // if it belongs to another oEdit, then close ig_calToDrop
     if(ig_calToDrop.oEdit != oEdit)
     {
      ig_showHideCal(null, false);
      // set reference in ig_calToDrop to this oEdit
      ig_calToDrop.oEdit = oEdit;
     }
     // show calendar with date from editor
     ig_showHideCal(oEdit.getDate(), true, true, true);
    }
    // synchronize dates in DateEdit and calendar, and show/close calendar
    function ig_showHideCal(date, show, update, toggle)
    {
     if(update != true) update = false;
     var oEdit = ig_calToDrop.oEdit;
     if(toggle == true && ig_calToDrop.isDisplayed == true)
      show = update = false;
     // update editor with latest date
     if(update && oEdit != null)
     {
      if(ig_calToDrop.isDisplayed) oEdit.setDate(date);
      else ig_calToDrop.setSelectedDate(oEdit.getDate());
     }
     // check current state of calendar
     if(ig_calToDrop.isDisplayed == show)
      return;
     // show/hide calendar
     ig_calToDrop.element.style.display = show ? "block" : "none";
     ig_calToDrop.element.style.visibility = show ? "visible" : "hidden";
     ig_calToDrop.isDisplayed = show;
     if(show)
      ig_setCalPosition();
     else
     {
      if(ig_frameUnderCal != null)
       ig_frameUnderCal.hide();
      ig_calToDrop.oEdit = null;
     }
    }
    // set position of calendar below DateEdit
    function ig_setCalPosition()
    {
     var edit = ig_calToDrop.oEdit.Element;
     var pan = ig_calToDrop.element;
     pan.style.visibility = "visible";
     pan.style.display = "";
     if(ig_frameUnderCal == null && ig_csom.IsIEWin)
     { 
      ig_frameUnderCal = ig_csom.createTransparentPanel();
      if(ig_frameUnderCal != null)
       ig_frameUnderCal.Element.style.zIndex = 10001;
     }
     var editH = edit.offsetHeight, editW = edit.offsetWidth;
     if(editH == null) editH = 0;
     var z, x = 0, y = editH, elem = edit, body = window.document.body;
     while(elem != null)
     {
      if(elem.offsetLeft != null) x += elem.offsetLeft;
      if(elem.offsetTop != null) y += elem.offsetTop;
      if(elem.nodeName == "HTML" && elem.clientHeight > body.clientHeight)
       body = elem;
      elem = elem.offsetParent;
     }
     var panH = pan.offsetHeight, panW = pan.offsetWidth;
     if((y - body.scrollTop) * 2 > body.clientHeight + editH)
      y -= (panH + editH);
     z = body.scrollLeft;
     if(x < z) x = z;
     else if(x + panW > (z += body.clientWidth)) x = z - panW;
     pan.style.left = x;
     pan.style.top = y;
     if(ig_frameUnderCal != null)
     {
      ig_frameUnderCal.setPosition(y - 1, x - 1, panW + 2, panH + 2);
      ig_frameUnderCal.show();
     }
    }
    // process mouse click events for page: close drop-down
    function ig_globalMouseDown(evt)
    {
     // find source element
     if(evt == null) evt = window.event;
     if(evt != null)
     {
      var elem = evt.srcElement;
      if(elem == null) if((elem = evt.target) == null) elem = this;
      while(elem != null)
      {
       // ignore events that belong to calendar
       if(elem == ig_calToDrop.element) return;
       elem = elem.offsetParent;
      }
     }
     // close calendar
     ig_showHideCal(null, false, false);
    }
    function ig_closeCalEvent(oEdit){ig_showHideCal(null, false);}
    function ig_initDropCalendar(calendarAndDates)
    {
     var ids = calendarAndDates.split(" ");
     ig_frameUnderCal = null;
     ig_calToDrop = igcal_getCalendarById(ids[0]);
     if(ig_calToDrop == null)
     {
      alert("WebCalendar with id=" + ids[0] + " was not found");
      return;
     }
     ig_calToDrop.element.style.zIndex = 10002;
     ig_calToDrop.element.style.position = "absolute";
     ig_calToDrop.isDisplayed = true;
     // hide drop-down calendar
     ig_showHideCal(null, false);
     // it is called by date click events of WebCalendar
     // Note: that name should match with the ClientSideEvents.DateClicked property
     //  which is set in aspx for WebCalendar
     ig_calToDrop.onValueChanged = function(cal, date)
     {
      // update editor with latest date and hide calendar
      ig_showHideCal(date, false, true);
     }
     // add listener to mouse click events for page
     ig_csom.addEventListener(window.document, "mousedown", ig_globalMouseDown);
     for(var i = 1; i < ids.length; i++)
     {
      var edit = igedit_getById(ids[i]);
      if(edit == null)
      {
       alert("WebDateTimeEdit with id=" + ids[i] + " was not found");
       continue;
      }
      edit.addEventListener("focus", ig_closeCalEvent, edit);
      edit.addEventListener("spin", ig_closeCalEvent, edit);
      edit.addEventListener("keydown", ig_closeCalEvent, edit);
      edit.addEventListener("custombutton", ig_openCalEvent, edit);
     }
    }
      
      </SCRIPT>
  • 相关阅读:
    计算器代码
    acm数论之旅(转载)---最大公约数与最小公倍数
    acm数论之旅(转载) -- 快速幂
    acm数论之旅(转载)--素数
    位运算符(转载)
    最短路问题
    并查集
    深度优先探索与广度优先探索
    ACM注意事项
    LTE Module User Documentation(翻译6)——物理误差模型、MIMO模型、天线模型
  • 原文地址:https://www.cnblogs.com/sutengcn/p/197835.html
Copyright © 2011-2022 走看看