Asp.net comes with a very good calendar control, but it still lacks the rendering method. Now we use a tip to easily create a pop-up date. Since then, you no longer have to go online to find the one with a lot of scripts.CodeThe JS-created pop-up date control.
The implementation method is simple: simply add JavaScript and some CSS to the page to create a simple pop-up date selector.
The. aspx code is as follows:
<Head id = "head1" runat = "server"> <br/> <title> No title page </title> <br/> <MCE: script Type = "text/JavaScript" Language = "JavaScript"> <! -- <Br/> function displaycalendar () <br/>{< br/> var datepicker = document. getelementbyid ("datepicker"); <br/> datepicker. style. display = 'block'; <br/>}</P> <p> // --> </MCE: SCRIPT> <br/> <MCE: style type = "text/CSS"> <! -- <Br/> # datepicker <br/> {<br/> display: none; <br/> position: absolute; <br/> border: solid 2px black; <br/> background-color: White; <br/>}</P> <p> --> </MCE: style> <style type = "text/CSS" mce_bogus = "1"> # datepicker <br/>{< br/> display: none; <br/> position: absolute; <br/> border: solid 2px black; <br/> background-color: white; <br/>}< br/> </style> <br/> </pead> <br/> <body> <br/> <Form ID = "form1" runat = "server"> <br/> <asp: label id = "label1" runat = "server" text = "Date:"> </ASP: Label> <br/> <asp: textbox id = "textbox1" runat = "server"> </ASP: textbox> <br/> <br/> <Div id =" datepicker "> <br/> <asp: calendar id = "calendar1" runat = "server" <br/> onselectionchanged = "calendar#selectionchanged"> </ASP: calendar> <br/> </div> <br/> <asp: button id = "button1" runat = "server" text = "button"/> <br/> </form> <br/> </body> <br/> </ HTML> <br/>
. Aspx. CS code:
Protected void calendar1_selectionchanged (Object sender, eventargs e) <br/>{< br/> textbox1.text = calendar1.selecteddate. tostring ("D"); <br/>}
Effect:
Tip 2:
When the gridview is used to present a lot of string records, and the width that can be set is very limited, we can use this technique of the tooltip attribute of the gridview. The tips are as follows:
Protected void gv_historyrecords_rowdatabound (Object sender, gridviewroweventargs e) <br/>{< br/> If (E. row. rowtype = datacontrolrowtype. datarow) <br/>{</P> <p> If (E. row. cells [2]. text. trim (). length> 7) <br/>{< br/> E. row. cells [2]. tooltip = E. row. cells [2]. text; <br/> E. row. cells [2]. TEXT = E. row. cells [2]. text. substring (0, 6) + "<B> .... </B> "; <br/>}< br/>}
It is mainly to first determine whether the character length of a field is greater than a set value. If it is greater than this value, the entire field value is saved to the tooltip attribute, then, extract the first number of characters and display them in the gridview.
Effect:
Of course, if you add some labels to The tooltip in the Code and set the display appearance, it will be more beautiful!