zoukankan      html  css  js  c++  java
  • AJAX Tool kit Combox

    AJAX Tool kit  Combox

    This is a sample of using AjaxToolkit Combox. I don't want to say it is good or not. We are just meet each other today and I feel like it very much.

    Here is the screen shot for this example.

    The first step is to add a combox to the page. Then configure its style and set its porperties. Don't forget to add scriptManager to your page. Ok, here is the style and the configured items. It's also available in the source code of ajaxtoolkit sample site.

    View Code
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AjaxComboBox.aspx.cs" Inherits="MySite.AjaxComboBox" %>

    <%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>

    <!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>
    <style type="text/css">
    .WindowsStyle .ajax__combobox_inputcontainer .ajax__combobox_textboxcontainer input
    {
    margin
    : 0;
    border
    : solid 1px #7F9DB9;
    border-right
    : 0px none;
    padding
    : 1px 0px 0px 5px;
    font-size
    : 13px;
    height
    : 18px;
    position
    : relative;
    }
    .WindowsStyle .ajax__combobox_inputcontainer .ajax__combobox_buttoncontainer button
    {
    margin
    : 0;
    padding
    : 0;
    background-image
    : url(/images/Combox/windows-arrow.gif);
    background-position
    : top left;
    border
    : 0px none;
    height
    : 21px;
    width
    : 21px;
    }
    .WindowsStyle .ajax__combobox_itemlist
    {
    border-color
    : #7F9DB9;
    }
    </style>
    </head>
    <body>

    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div>
    <asp:ComboBox ID="ComboBox1" runat="server" Width="200px"
    AutoPostBack
    ="false"
    DropDownStyle
    ="DropDown"
    AutoCompleteMode
    ="SuggestAppend"
    CaseSensitive
    ="False"
    CssClass
    ="WindowsStyle"
    ItemInsertLocation
    ="Append">
    </asp:ComboBox>
    </div>
    </form>
    </body>
    </html>

    Do you know how to fetch data from database? here is the source code if you are interested:

    View Code
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Configuration;
    using System.Text;
    using System.Data;
    using System.Data.SqlClient;
    using System.IO;
    using System.Drawing;
    using System.Web.UI.HtmlControls;

    namespace MySite
    {
    public partial class AjaxComboBox : System.Web.UI.Page
    {
    protected void Page_Load(object sender, EventArgs e)
    {
    if (!IsPostBack)
    {
    LoadUsers();
    }
    }

    protected void LoadUsers() {
    string cmdText = "";
    string connString = ConfigurationManager.ConnectionStrings["testConnectionString"].ToString();

    StringBuilder sbuilder
    = new StringBuilder("Select ");
    //sbuilder.AppendLine("ID");
    sbuilder.AppendLine("EMPNO");
    sbuilder.AppendLine(
    ",NAME");
    //sbuilder.AppendLine(",AGE");
    sbuilder.AppendLine("From TEST");

    cmdText
    = sbuilder.ToString();
    DataSet ds
    = new DataSet();
    using (SqlConnection conn = new SqlConnection(connString))
    {
    SqlCommand cmd
    = new SqlCommand(cmdText, conn);
    SqlDataAdapter da
    = new SqlDataAdapter(cmd);
    da.Fill(ds);
    }
    ComboBox1.DataSource
    = ds;
    ComboBox1.DataTextField
    = "NAME";
    ComboBox1.DataValueField
    = "EMPNO";
    ComboBox1.DataBind();
    ComboBox1.Items.Insert(
    0,"");
    }
    }
    }

    Have u got the data you want? :)

  • 相关阅读:
    5.2 二叉树的创建和遍历
    5 树
    Word2013发布博客到博客园的详细方法
    synergy--共享你的键鼠
    二十三 Python分布式爬虫打造搜索引擎Scrapy精讲—craw母版l创建自动爬虫文件—以及 scrapy item loader机制
    二十二 Python分布式爬虫打造搜索引擎Scrapy精讲—scrapy模拟登陆和知乎倒立文字验证码识别
    二十一 Python分布式爬虫打造搜索引擎Scrapy精讲—爬虫数据保存
    二十 Python分布式爬虫打造搜索引擎Scrapy精讲—编写spiders爬虫文件循环抓取内容—meta属性返回指定值给回调函数—Scrapy内置图片下载器
    十九 Python分布式爬虫打造搜索引擎Scrapy精讲—css选择器
    十八 Python分布式爬虫打造搜索引擎Scrapy精讲—Scrapy启动文件的配置—xpath表达式
  • 原文地址:https://www.cnblogs.com/Dannier/p/1985082.html
Copyright © 2011-2022 走看看