2017-5-19复合控件

Zoe Zoe     2022-09-02     395

关键词:

(一)复合控件

1.RadioButtonList   每一行数据都是一个ListItem

RadioButtonList的属性:

          RepeatDirection --- 排列方式

    RepeatColumns --- 每一行中需要展示的个数

    RepeatLayout  --- 页面中生成什么样的代码

ListItem的属性: 

             Enable  --- 是否启用

     selected  --- 是否被选中

    Text  ---  显示的文本  

            Value  ---隐藏的值,给系统看的

2.  RadioButtonList绑定数据:

绑定数据有两种方式:
(1)、DataSource

 

(2)遍历创建ListItem

取值:

void Button1_Click(object sender, EventArgs e)
    {
        Label1.Text= RadioButtonList1.SelectedItem.Text//显示的内容
      +RadioButtonList1.SelectedItem.Value;//给数据库看的内容 }

 3.CheckBoxList

绑定数据:RadioButtonList一样,两种方式:   DataSource数据源绑定和   遍历创建ListItem 绑定

取值:(遍历创建ListItem方式

void Button1_Click(object sender, EventArgs e)
    {
        string a = "";
        foreach(ListItem li in CheckBoxList1.Items)
        {
            if (li.Selected) 
            {
                a += li.Text;
            }
        }
        Label1.Text = a;
    }

注意:点击复选框的时候,lable显示点击的内容:在checkbox中写事件SelectedIndexChange,一定要加入自动
提交属性AutoPostBback="true";
//改变事件代码:
  if (CheckBoxList1.SelectedIndex >= 0)
            Label1.Text = CheckBoxList1.SelectedItem.Text;
        else
            Label1.Text = "";
//checkbox中的代码
 <asp:CheckBoxList AutoPostBack="true" ID="CheckBoxList1" runat="server" OnSelectedIndexChanged="CheckBoxList1_SelectedIndexChanged"></asp:CheckBoxList>

4.DropDownList  下拉列表

赋值:和复合控件checkboxlist,radiobuttonlist一样

protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack == false) 
        {
            List<Nation> ulist = new NationData().select();
            CheckBoxList1.DataSource = ulist;
            CheckBoxList1.DataTextField = "NationName";
            CheckBoxList1.DataValueField = "NationCode";
            CheckBoxList1.DataBind();
            ListItem la = new ListItem("==请选择==","-1");
            DropDownList1.Items.Add(la);
            foreach (Nation uu in ulist)
            {
                ListItem li = new ListItem(uu.NationName, uu.NationCode);
                DropDownList1.Items.Add(li);
            }

        }
        Button1.Click += Button1_Click;

    }

取值

void Button1_Click(object sender, EventArgs e)
    {
        Label1.Text = DropDownList1.SelectedItem.Text;
       
    }

5.ListBox   列表控件

属性:selectionmode设置是否多选,multiple多选,single单选

取值,赋值和控件checkboxlist,radiobuttonlist,dropdownlist一样

(二)ispostback

绑定数据出现数据选项无法更改
page_load事件再每一次页面刷新的时候都会执行
就会把数据重新绑定一次,再去执行按钮事件
判断页面是否是第一次加载还是响应回发

if(!ispostback)
{
只需要在页面第一次加载的时候才执行的代码写到这里面
注意95%的代码都要写到这里面
!事件委托不能写到这里面
}

 

(三)跨页面传值

1.页面跳转:在本窗口中

Response.Redirect("文件路径");

2.页面传值:传递的值可以是很多个,不固定的

  用的是QueryString   --- url传值,或者地址栏传值

  接在那个网址后面,就给哪个传值,

  样式:地址?key=value&key=value,key就相当于是一个变量,名称,用来存贮的

 

  接收:string value = Request["key"];

例子: 

     Response.Redirect("aaa.aspa?a="+TextBox1.Text);

 

aaa页面中的接收,并且在label中显示:string aa = Request["a"]; label1.text=aa;

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default1.aspx.cs" Inherits="Default1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
        <asp:Button ID="Button1" runat="server" Text="Button" />
    </div>
    </form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Default1 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Button1.Click += Button1_Click;
    }

    void Button1_Click(object sender, EventArgs e)
    {
        Response.Redirect("Default2.aspx?a="+TextBox1.Text+"&b="+TextBox2.Text);
    }
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    </div>
    </form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string s=Request["a"];
        string ss = Request["b"];
        Label1.Text = s+ss;
    }
}

 

3.打开新页面窗口:

 Response.Write("<script>window.open('Default2.aspx','_blank');</script>");


 

2017-5-19复合控件ispostback跨页面传值

(一)复合控件1.RadioButtonList 每一行数据都是一个ListItem属性:RepeatDirection---排列方式    RepeatColumns---每一行中需要展示的个数    RepeatLayout ---页面中生成什么样的代码    Enable ---是否启用    sele... 查看详情

delphi控件-复合控件

复合控件复合控件是Delphi控件中非常重要的一种控件,复合控件就是将两个或两个以上的控件重新组合成一个新的控件。例如TspinEdit、TlabeledEdit、TDBNavigator等就是复合控件,TDBNavigator其实就是在一个Panel放上若干个Button而已。制... 查看详情

2017.5.19mslocalpartnertraining

Itaughtmsdataplatformandpowerbisolutionformslocalpartner.thiseventwasafreeofcharge.Partnersareenthusiasticaboutlearningmssqlandpowerbitechnology. 查看详情

Android 片段与复合控件

】Android片段与复合控件【英文标题】:Androidfragmentsvscompoundcontrols【发布时间】:2011-09-0701:43:06【问题描述】:为什么要使用Android3.0片段而不是复合控件?可以一次创建一个View继承器或复合控件,然后在任何地方使用它。我已... 查看详情

复合控件中公开子控件事件

publicclassUserControl1:UserControl{//privateButtonsaveButton;publiceventEventHandlerSaveButtonClick{add{saveButton.Click+=value;}remove{saveButton.Click-=value;}}}  查看详情

2017-5-19rabbit-mq

2017-5-19rabbit-mq新建模板小书匠欢迎使用小书匠(xiaoshujiang)编辑器,您可以通过设置里的修改模板来改变新建文章的内容。rabbitmq的各项优化http://www.blogjava.net/qbna350816/archive/2016/08/02/431415.aspxrabbitMQ安装命令./configure--prefix=/home/zsztest... 查看详情

如何验证复合控件

】如何验证复合控件【英文标题】:howtovalidatecompositecontrols【发布时间】:2012-12-0217:03:15【问题描述】:好吧,这有点复杂。我有一个包含文本框、必填字段验证器和一个按钮的复合控件。它公开了一个名为ValidationGroup的属性。... 查看详情

复合控件选择类

复合控件:  多选框:checkbox-CheckBoxList      属性:RepeatLayout:Table 按表格排布  Flow流排布       RepeatDirection:Vertical垂直排布  Horizontal水平排布       RepeatColumns:每一行有几列&nb... 查看详情

webform(简单控件复合控件)

一、简单控件:1.label控件<asp:LabelID="Label1"runat="server"Text="账号:"></asp:Label>被编译为:<spanid="Label1">账号:</span>属性:Text:文本ForeColor:字体颜色Visible:是否可见CssClass:即HTML的class2.Literal类似lab 查看详情

复合控件

RadioButtonList--单选RadioButtonList1.DataSource= 等于一个集合   --指向数据源 RadioButtonList1.DataTextField="NationName";  --网页中显示的内容       &n 查看详情

复合控件:选择类(代码片段)

复合控件:  多选框:checkbox-CheckBoxList      属性:RepeatLayout:Table 按表格排布  Flow流排布       RepeatDirection:Vertical垂直排布  Horizontal水平排布       RepeatColumns:每一行有几列&nb... 查看详情

表单元素,简单控件,复合控件

十二个表单元素:文本类:<inputtype="text"/>//普通的文本框<inputtype="password"/>//密码框<textarea><textarea/>//可多行编辑的文本域<inputtype="hidden"/>//隐藏域选择类:<inputtype="radio"id="i"/><label 查看详情

1014简单控件和复合控件

简单控件Label-被Html编译成<span>Literal-什么元素都没有,只会在位置上将Text内容完全展示出来,可以形成jsTextBox-下面有详细介绍Button-就是按钮ImageButton-图片按钮LinkButton-超链接样式的按钮因为程序安装在客户端,所以js执行顺序... 查看详情

2017-5-19&5-23/系统性能指标

1.系统性能指标包括哪些?业务指标、资源指标、中间件指标、数据库指标、前端指标、稳定性指标、批量处理指标、可扩展性指标、可靠性指标。1)业务指标:主要包括并发用户数、响应时间、处理能力。指标定义简称标准交... 查看详情

复合控件

1、label。后台编译Span(1)ForeColor字体颜色(2)设置label的Height,Width之前,必须先设置:Display=“inLine-block”;(3)Text:文本内容。(4)visible:权限使用(5)CssClass:使用的样式表2、Literal。后台编译啥也没有(1)Text:文本内容。但是可以对L... 查看详情

复合控件

1、CheckBox(在网页中被编译成<inputtype="checkbox">)<asp:CheckBoxID="CheckBox1"runat="server"/Text="呵呵">(CheckBox中有text属性,“呵呵”在网页中被编译成“<labelfor="CheckBox1">呵呵</label>”)取值:if(CheckBox1.C 查看详情

wpf复合控件焦点设置

参考技术A定义一个密码框的复合控件,最外层是Border,内部有三个控件分别是Image,GridSplitter,PasswordBox.当键盘输入完账号通过tab键跳转到密码框,会发现焦点不在PasswordBox上而是跑到了GridSplitter上,并有虚框。那为什么Image没有获... 查看详情

webform复合控件

DropDownList下拉列表会被编译为selectoptionps.name服务端常用,id客户端常用一般用法:一、将数据放进去  方法一:同WinForm相同,给定数据源,然后绑定数据DropDownList1.DataSource=newNationData().Select();//数据源指向DropDownList1.DataText... 查看详情