AjaxPro局部重新整理(輸入時自動提示功能)

來源:互聯網
上載者:User

標籤:style   blog   http   color   java   使用   os   io   


1.前台頁面

 

         <td class="queryLeft">股票名稱:</td>         <td class="queryRight">             <asp:TextBox ID="txtShareName" CssClass="shareName" onkeyup="prompt(this)" runat="server" autocomplete="off"></asp:TextBox>  //okeyup()按下鍵盤時觸發。autocomplete:消除瀏覽器的記錄    
// 隱藏div <div id="prompt" style="display: none; min-width: 120px; position: absolute; top: 200px; line-height: 20px; border: 1px solid #ccc; border-top: 0px; background-color: #fff; padding: 0px 5px; z-index: 1000;"></di> </td>

 1.2 js代碼

//填充滑鼠背景色
function setMouseEvent() { $(".hide_share").mousemove(function () { $(this).css("background-color", "#C9C9C9").siblings().css("background-color", " #fff"); }).mouseout(function () { $(this).css("background-color", " #fff") }); };
//調用後代碼,局部重新整理 function prompt(obj) { var str = $(obj).val(); if (str.trim() == "" || event.keyCode == 13) { $("#prompt").hide(); $("#prompt").html(""); } var str = Lcp.Share.Admin.Web.ShareMaintenace.GetAllShareList(str).value; if(str == "") { $("#prompt").hide(); return; } $("#prompt").html(str); $("#prompt").show(); setMouseEvent(); }
//填充文字框 function fullShareName(share_name) { $(".shareName").val(share_name); $("#prompt").hide()

 1.3 後台代碼

 protected void Page_Load(object sender, EventArgs e)        {            AjaxPro.Utility.RegisterTypeForAjax(typeof(ShareMaintenace)); //引用 ajaxPro
if (!IsPostBack) { BindData(0); } }

 (注意“\”轉意字元使用)

 [AjaxPro.AjaxMethod]        public string GetAllShareList(string shares)        {            string share = shares;            string shareMsg = "";            if (!string.IsNullOrEmpty(share))            {                IShareService service = Kernel.GetService<IShareService>();                ShareDataGetResponse scp = service.GetShareDataGetResponse(share);                scp.ShareDataList.ForEach(o =>                {                                        shareMsg += "<a class=‘hide_share‘ style=‘display:block;‘ href=‘javascript:void(0);‘ onclick=\"fullShareName(‘" + o.ShareName + "‘)\">" + o.ShareCode + "&nbsp;&nbsp;" + o.ShareName + "</a> ";                });            }            return shareMsg;        }

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.