专题图编号:ylbtechASPNET

1,功能描述

搜索查询,如何保存查找条件。

2,技术与环境
3,数据库设计
4,功能截图

4.1,前台

4.1.1

4.1.2

5,代码分析

解决方案属性图
5.1 方案一

  DropSearchDemo.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DropSearchDemo2.aspx.cs" Inherits="DropSearch_DropSearchDemo2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript" src="jquery-1.3.2.min.js"></script>
    <script type="text/javascript">
        function search(keyword, type) {
            var keyword = $("#" + keyword).val();
            var type = $("#" + type).val();
            window.location.href = "?keyword=" + myescape(keyword) + "&type=" + type;
        }
        function myescape(str) {
            return escape(str).replace("+", "%2B");
        }
    </script>
</head>
<body>
   <form action="DropSearchDemo2.aspx" method="get">
    <table border="1" width="600px">
        <tr>
            <td>
                商品索索:
            </td>
            <td>
                <select id="type" name="type">
                    <option value="1">图片</option>
                    <option value="2">新闻</option>
                    <option value="3">娱乐</option>
                </select>
            </td>
            <td>
                <input id="keyword" runat="server" name="keyword" type="text" autocomplete="off"
                onkeydown="javascript:if(event.keyCode==13){search('keyword','type');return false;}"  />
            </td>
            <td>
                <input type="button" value="Search" onclick="search('keyword','type')" />
            </td>
        </tr>
    </table>
    <!--begion 设默认选择类型-->
    <%--<script>
        $("#type").val(2);
    </script>--%>
    <!--end 设默认选择类型-->
    <asp:Literal ID="LSelectDefault" runat="server"></asp:Literal>
    </form>   
     
</body>
</html>

DropSearchDemo.aspx.cs

using System;
public partial class DropSearch_DropSearchDemo : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(Request["type"])) //分类,存在则设默认
        {
            string type=Request["type"];
            LSelectDefault.Text = "<script> document.getElementById('type').value = "+type+";</script>";
        }
        if (!string.IsNullOrEmpty(Request["keyword"])) 关键字,存在则设默认
        {
            keyword.Value = Request["keyword"];
        }
    }
}

5.2,方案二

DropSearchDemo2.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DropSearchDemo2.aspx.cs" Inherits="DropSearch_DropSearchDemo2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript" src="jquery-1.3.2.min.js"></script>
    <script type="text/javascript">
        function search(keyword, type) {
            var keyword = $("#" + keyword).val();
            var type = $("#" + type).val();
            window.location.href = "?keyword=" + myescape(keyword) + "&type=" + type;
        }
        function myescape(str) {
            return escape(str).replace("+", "%2B");
        }
    </script>
</head>
<body>
   <form action="DropSearchDemo2.aspx" method="get">
    <table border="1" width="600px">
        <tr>
            <td>
                商品索索:
            </td>
            <td>
                <select id="type" name="type">
                    <option value="1">图片</option>
                    <option value="2">新闻</option>
                    <option value="3">娱乐</option>
                </select>
            </td>
            <td>
                <input id="keyword" runat="server" name="keyword" type="text" autocomplete="off"
                onkeydown="javascript:if(event.keyCode==13){search('keyword','type');return false;}"  />
            </td>
            <td>
                <input type="button" value="Search" onclick="search('keyword','type')" />
            </td>
        </tr>
    </table>
    <!--begion 设默认选择类型-->
    <%--<script>
        $("#type").val(2);
    </script>--%>
    <!--end 设默认选择类型-->
    <asp:Literal ID="LSelectDefault" runat="server"></asp:Literal>
    </form>   
     
</body>
</html>

DropSearchDemo2.aspx.cs

using System;
public partial class DropSearch_DropSearchDemo2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(Request["type"])) //分类,存在则设默认
        {
            string type = Request["type"];
            LSelectDefault.Text = "<script> $('#type').val("+type+");</script>";
        }
        if (!string.IsNullOrEmpty(Request["keyword"])) 关键字,存在则设默认
        {
            keyword.Value = Request["keyword"];
        }
    }
}

6,示例|讲解案例下载

博客园讲解:  http://ylbtech.cnblogs.com/

百度文库开发文档: http://passport.baidu.com/?business&aid=6&un=ylbtech#7

谷歌开源代码下载: http://code.google.com/p/ylbtechopensource/downloads/list

请单击“搜索框设默认DropDown”

本文转自ylbtech博客园博客,原文链接:http://www.cnblogs.com/ylbtech/archive/2012/09/05/2670755.html,如需转载请自行联系原作者

ASP.net:查找框设默认相关推荐

  1. 关于input type=“text”文本框的 默认宽度

    当文本框的td设置宽度设置为百分比时,出现了一些没有搞懂的地方. 类选择设置td的width 为百分比时,通常 要定义父元素的宽度,在我的实战中父元素只能是table,给定table时. 而且这就是说 ...

  2. 如何更改Twitter Bootstrap模式框的默认宽度?

    本文翻译自:How can I change the default width of a Twitter Bootstrap modal box? I tried the following: 我尝 ...

  3. php一些单选、复选框的默认选择方法(示例)

    转载 http://www.php.cn/php-weizijiaocheng-360029.html 一. radio和checkbox及php select默认选择的实现代码 1.radio单选框 ...

  4. antdesign的表单中的下拉框设置默认值BUG处理

    问题: 使用 antdesign 下拉框的默认值是状态值,而不是状态值对应的文案? model层传递的数据 view层在表单中设置的值 解决方案: 在默认值的后面加上一个空字符串进行转换

  5. html下拉框设置默认值_如何设置HTML select下拉框的默认值?

    HTML中的select标签用于创建可选择选项的下拉列表:option标签包含选定时将使用的值.那么如何来设置select下拉框里的默认值?下面本篇文章就来给大家介绍一下,希望对大家有所帮助. 我们可 ...

  6. [css] css怎么更改表单的单选框或下拉框的默认样式?

    [css] css怎么更改表单的单选框或下拉框的默认样式? 下拉框select可以通过appearance:none去除默认样式,然后进行自定义,但是option标签不能通过CSS自定义,所以最佳方案 ...

  7. php查询框,html查找框功能

    html页面的查找功能主要是实现在查找框内输入字符,下面通过本文给大家分享html页面的查找功能,需要的朋友参考下吧 最近在搞一个被很多人改了的框架,天天看代码看的头的晕了,不过感觉进步还挺大的,自己 ...

  8. Stimulsoft Reports ASP.NET HTML5报表设计器

    2019独角兽企业重金招聘Python工程师标准>>> 关于Stimulsoft Reports报表工具,最近一次更新可以说让他有太多的变化了.今天我们就要来写一点关于ASP.NET ...

  9. html select 样式t调整_用纯css改变下拉列表select框的默认样式

    **社区评论 ( Beta版 )** #0 危汤讽 2015-04-02 09:57:05 firefox浏览器支持不好,貌似是浏览器bug 回复 #1 林甩土 2015-04-03 09:06:57 ...

最新文章

  1. AI工程的实践者:普元积极将场景落地,为企业提供智能化解决方案
  2. Git Manual / Git使用手册 / Git, GitLab, Git Bash, TortoiseGit (建议全文复制到Word文档中通过导航窗格查看)...
  3. elasticsearch(es)分布式全文检索引擎 简介
  4. Servlet优化之BaseServlet
  5. 深入理解CachingConnectionFactory
  6. 一个系统中同时使用VC6.0+OpenCV1.0和VS2010+OpenCV2.4.6.0的方法
  7. IndentationError: expected an indented block --python报错 or IndentationError:unexpected indent
  8. 34岁程序员面试被拒:混得好的年轻人都有这3个特质
  9. 差值多项式的余项定理
  10. RPG游戏-NPC系统
  11. c语言调用abs需要加什么作用,c语言中abs函数怎么用
  12. 【冷冻电镜|论文阅读】A feature-guided, focused 3D signal permutation method for subtomogram averaging
  13. 232转can转换器 最新工艺
  14. Android Menu 之 ContextMenu 详解
  15. 关于BIOS升级的方法
  16. 4.5 没有自学,不是大学——《逆袭大学》连载
  17. Python+Vue计算机毕业设计美食网站设计与实现62e76(源码+程序+LW+部署)
  18. 前端js实现本地模糊搜索
  19. 购买重疾险的十大误区(建议收藏)
  20. 计算机图形学的主要研究内容是什么?

热门文章

  1. Recommender Systems基于内容的推荐
  2. 使用Lucene分词
  3. 我的Dll(动态链接库)学习笔记
  4. flutter中的生命周期函数
  5. IndexedDB 索引数据库
  6. C# 多线程參数传递
  7. SendDlgItemMessage
  8. C语言编程,从菜鸟到高手
  9. 雷林鹏分享:PHP 超级全局变量
  10. OOM分析之问题定位(二)