With pictures, multi-column DROPDOWNLIST (Mencius)

xiaoxiao2021-03-06  92

Below is the effect of imitating DropDownList, supporting pictures, multi-columns, wraps, etc. View example

WebdropDownList.aspx

<% @ Page language = "c #" Codebehind = "WebDropDownList.aspx.cs" validateRequest = "false" AutoEventWireup = "false" Inherits = "eMeng.WebDropDownList"%> analog dropdown list </ title> <meta http-equiv = "content-type" content = "text / html; charset = GB2312"> <style> body {font: 12px Song} TD {font: 12px Song} Div {FONT: 12PX Song } Label {padding-right: 0px; padding-left: 4px; padding-bottom: 3px; height: 19px} .link_box {cursor: default; text-align: left} .link_head {border-right : 2px INSET; Border-top: 2px INSet; Border-Left: 2px INSET; Width: 100%; Border-Bottom: 2px INSET; Height: 23px} .link_text {padding-left: 2px; Background: #fff} .link_arrow0 {Border-Right: 2px outset; BiRDER-TOP: 2PX OutSet; Background: Buttonface; font: 14px marlett; border-left: 2px outset; width: 22px; border-bottom: 2px outset; Height: 100%; Text-Align; TEXT-ALIGN : buttonshadow 1px solid: Buttingshadow 1PX Solid; Padding-Right: 0px; border-top: Buttonshadow 1PX Solid; Padding-Left: 2px; Background: ButtonFace; Padding -Bottom: 0px; font: 14px marlett; border-left: Buttonshadow 1px solid; width: 22px; padding-top: 2px; border-bottom: buttonshadow 1px solid; height: 100%; text-align: center} .link_value { Border-right: 1px solid; border-top: 1px solid; filter: alpha (Opacity: 0); visibility: hidden; overflow-x: hidden; overflow: auto; border-left: 1px solid; border-bottom: 1px solid; Position: absolute} .link_record0 {border-top: #eee 1px solid; padding-left: 2px; background: #fff; width: 100%; color: # 000; height: 20px} .link_record1 {border-top: # 047 1PX Solid; Padding-Left: 2px; Background: # 058; Width: 100%; Color: # Fe0;</p> <p>HEIGHT: 20px} </ style> <script> var dropShow = falsevar currentIDfunction dropdown (el) {if (dropShow) {dropFadeOut ()} else {currentID = elel.style.visibility = "visible" dropFadeIn ()}} function dropFadeIn () {// menu fade effect if (currentID.filters.alpha.opacity <100) {currentID.filters.alpha.opacity = 20fadeTimer = setTimeout ( "dropFadeIn ()", 50)} else {dropShow = trueclearTimeout (fadeTimer )}} function dropFadeOut () {// menu fade out if (currentID.filters.alpha.opacity> 0) {clearTimeout (fadeTimer) currentID.filters.alpha.opacity- = 20fadeTimer = setTimeout ( "dropFadeOut ()", 50)} else {dropShow = falsecurrentID.style.visibility = "hidden"}} function dropdownHide () {if (dropShow) {dropFadeOut () dropShow = false}} function hiLight (el) {// if the highlighted position indicators (dropShow) {for (i = 0; i <el.parentElement.childNodes.length; i ) {el.parentElement.childNodes (i) .className = "link_record0"} el.className = "link_record1"}} function CheckMe ( EL) {// Replace display content Document.all.Text1.innertext = El.innertext} Document.οnclick = DropdownHide </ script> </ head> <body text = "# 000000" οnlοad = "Document.All.form1. RESET () > <div sty = "padding: 10px; border-bottom: 2px solid red"> Analog drop-down box </ div> <form id = "Form1" οnsubmit = "Alert (city.value)" Runat = "Server"> <Table> <Tr> <TD> <Div Class = "LINK_BOX" ONSELECTSTART = "Return False" style = "width: 100px"> <div class = "link_head" οnclick = "Dropdown (Value1)> <Table Height = "100%" cellspacing = "0" cellpadding = "0" width = "100%" border = "0"</p> <p>> <tr> <td> <div class = "limited"> <nobr> <label id = "text1"> Please choose? </ label> </ nobr> </ div> </ td> <td align = "right" width = "22"> <div οnmοuseup = "this.classname = 'link_arrow0'" class = "=nmοusedοwn =" THIS.CLASSNAME = 'link_arrow1' "οnmοuseοut =" this.classname = 'link_arrow0' "> 6 </ div> </ td> </ tr> </ table> </ div> <div class =" link_value "id = "Value1" style = "width: 500px; height: 300px"> <ask: DataGrid ID = "DataGrid1" runat = "server" autogeneratecolumns = "false" font-size = "12px" width = "100%" showheader = " False "> <columns> <asp: boundcolumn datafield =" Title "sortexpression =" title "dataformatstring =" <img src = 'http: ///dotnet.aspx.cc/images/meng.gif' align = 'Absmiddle'>> {0} "> </ ask: BoundColumn DataField =" createDate "sortexpression =" create "headertext =" "DataFormatString =" {0: YYYY MM Month Day}> </ asp: boundcolumn> </ Columrid> <div id> <div id = "mx"> <div class = "link_record0" οnmοuseοver = "Hilight (this)" οnclick = "checkme (this); Document.all.form1.city.value = this.innertext "> <label> Beijing </ label> </ div> <div class =" οnmοuseοver = "οnclick =" Checkme (this); Document.all.form1.city.value =</p> <p>"innertext"> <label> Shanghai </ label> </ div> <div class = "link_record0" οnmοuseοver = "hilight (this)" οnclick = "checkme (this); Document.all.form1.city.value = this.innertext "> <label> Henan </ label> </ div> <div class =" link_record0 "οnmοuser =" Hilight (this) "οnclick =" Checkme (this); Document.All.form1.city. Value = this.innertext "> <label> Shenzhen </ label> </ div> <div class =" link_record0 "οnmοuseοver =" Hilight (this) "οnclick =" Checkme (this); Document.All.form1.city .value = this.innertext "> <label> Dalian </ label> </ div> <div class =" link_record0 "οnmοuseοver =" Hilight (this) "οnclick =" checkme (this); document.all.form1. City.value = this.innerText "> <label> Yunnan </ Label> </ div> </ div> <td> <input type =" hidden "value = "You have not selected" Name = "City"> <input type = "submit" value = "OK"> </ td> </ tr> </ table> </ form> </ body> </ html> WebDropdownList. aspx.cs</p> <p>using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls Using system.web.ui.htmlcontrols; using system.data.oledb;</p> <p>Namespace Emeng {/// <summary> /// Showlist's summary description. /// </ summary> public class webdropdownload: system.web.ui.page {protected system.web.ui.webcontrols.dataGrid DataGrid1;</p> <p>private void Page_Load (object sender, System.EventArgs e) {DataGrid1.Columns [0] .ItemStyle.Width = Unit.Pixel (400); DataGrid1.Columns [1] .ItemStyle.Width = Unit.Pixel (100); Data_Bind ();} public void Data_Bind () {Response.CacheControl = "no-cache"; Response.Expires = -1; try {string strSQL = "SELECT id, objectGuid, Title, CreateDate, HitCount FROM Document ORDER BY id DESC" ; string cnString = (new Connection ()) ConnectionString;. OleDbConnection cn = new OleDbConnection (cnString); cn.Open (); OleDbCommand cmd = new OleDbCommand (strSQL, cn); DataGrid1.DataSource = cmd.ExecuteReader (CommandBehavior.CloseConnection ); DataGrid1.databind (); cn.close (); cn.dispose (); cn = null; cmd.dispose (); cmd = null;} catch (oledbException myoledbexception) {response.write ("error:" myOleDbException.Message ":" myOleDbException.HelpLink); Response.End ();}} private void DataGrid1_ItemDataBound (object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) {</p> <p>IF (E.Item.itemindex! = -1) {E.Item.attributes.add ("onmouseover", "this.bgcolor = '# c1d2ee'); E.Item.attributes.add (" onclick "," Document.all.Text1.innertext = this.cells [0] .innerText; Document.all.form1.city.value = this.cells [0] .innerText; "); if (E.Item.itemindex% 2 == 0) {E.Item.attributes.add ("BGColor", "#fffffff"); E.Item.attributes.add ("onmouseout", "this.bgcolor = document.getlementByid ('datagrid1'). GetAttribute (' SINGLEVALUE ') ");} else {E.Item.attributes.add (" BGColor "," Oldlace "); E.Item.attributes.add (" onmouseout "," this.bgcolor = document.getlementByid (' datagrid1 ' ) .getattribute ('OldValue') ");}} else {datagrid1.attributes.add (" oldvalue "," oldlace "); DataGrid1.attributes.add (" SINGLEVALUE "," #ffffff ");}} # region Web Form Designer Generated CodeOverride Protected Void OnNit (Eventargs E) {/// Codegen: This call is required for the ASP.NET Web Form Designer. //InitializeComponent ();Base.onit (E ); }/// <summary> /// Designer Supports the required method - Do not use the code editor to modify the /// this method. /// </ summary> private void InitializeComponent () {this.DataGrid1.ItemDataBound = new System.Web.UI.WebControls.DataGridItemEventHandler (this.DataGrid1_ItemDataBound); this.Load = new System.EventHandler (this.Page_Load) ;} # endregion}}}</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-122761.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="122761" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.034</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'wWTtOGhu_2FoR0iERqTl8uck_2BX5duDjAxeu3glhcMgVk0rk1W2No5VZA1_2F07_2F6oldXkVnHeoI6IX9APVL4bNnDFQ_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>