简单数据绑定
2012-11-30 14:28
134 查看
前台
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="dataBind1.aspx.cs" Inherits="ASPdotNetSUPPER1.dataBind1" %>
<!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>
</head>
<body style='background-color:<%# this.DropDownList1.SelectedValue%>'>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True">
</asp:DropDownList>
</div>
</form>
</body>
</html>
<%#js %>
后台
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace ASPdotNetSUPPER1
{
public partial class dataBind1 : System.Web.UI.Page
{
private string color;
public string Color
{
get { return this.color; }
}
protected string js;
protected void Page_Load(object sender, EventArgs e)
{
color = "blue";
js = "<script>alert('hello bind!');</script>";
if (!IsPostBack)
{
this.DropDownList1.Items.Add(new ListItem("红色", "red"));
this.DropDownList1.Items.Add(new ListItem("蓝色","blue"));
}
this.DataBind();
}
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="dataBind1.aspx.cs" Inherits="ASPdotNetSUPPER1.dataBind1" %>
<!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>
</head>
<body style='background-color:<%# this.DropDownList1.SelectedValue%>'>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True">
</asp:DropDownList>
</div>
</form>
</body>
</html>
<%#js %>
后台
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace ASPdotNetSUPPER1
{
public partial class dataBind1 : System.Web.UI.Page
{
private string color;
public string Color
{
get { return this.color; }
}
protected string js;
protected void Page_Load(object sender, EventArgs e)
{
color = "blue";
js = "<script>alert('hello bind!');</script>";
if (!IsPostBack)
{
this.DropDownList1.Items.Add(new ListItem("红色", "red"));
this.DropDownList1.Items.Add(new ListItem("蓝色","blue"));
}
this.DataBind();
}
}
}
相关文章推荐
- springMVC对简单对象、Set、List、Map的数据绑定和常见问题
- AngularJS简单的数据绑定
- 五十行javascript代码实现简单的双向数据绑定
- silverlight简单数据绑定1
- WPF 简单数据绑定实例
- Flex4 数据绑定简单示例
- DataGrid 简单数据绑定实例1
- ADO.NET Entity Framework 一个简单数据绑定例子
- 如何用javascript实现双向数据绑定 / Backbone.js简单入门范例
- RDLC报表系列(一) 简单的动态数据绑定和配置
- asp.net Xml绑定到数据控件的两种简单方法
- WPF学习笔记(04) - 简单的控件和数据绑定
- 简单的js数据双向绑定
- 数据绑定控件 简单分页
- WPF ListView 简单的数据绑定
- springMVC对简单对象、Set、List、Map的数据绑定和常见问题(二)
- 一个简单的win8数据绑定
- uwp开发:数据绑定——值转换器 的简单使用
- Data Binding 的使用之一:简单的数据绑定
- GridView与SQLDataSource简单数据绑定