asp.net 取得用户控件里的属性或控件
最近在用用户控件时,引用户控件的页面有时候会和用户控件进行数据的交互,网上好像很多人不知道何获取
写个例子说明一下
取得用户控件里面的控件并进行赋值
用户控件aspx页代码
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="HeadPanel.ascx.cs" Inherits="HeadPanel" %>
<asp:Label ID="lb1" runat="server" Text=""></asp:Label> //在用户控件里定义 的两个控件
<asp:Label ID="lb2" runat="server" Text=""></asp:Label>
cs页代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class HeadPanel : System.Web.UI.UserControl
{
public static string tmpSiteName = "用户控件进行赋值的标题";
public string tmpStr="这是用户变量";
protected void Page_Load(object sender, EventArgs e)
{
}
}
引用用户控件aspx页代码
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Src="HeadPanel.ascx" TagName="RegHead" TagPrefix="uc" %>
<!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 id="Head1" runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>
<title><%= HeadPanel.tmpSiteName%></title> //HeadPanel是用户控件cs页的类名,tmpSiteName是用户控件里的静态变量
</head>
<body>
</body>
</html>
引用用户控件cs页代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Text;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(
相关文档:
ASP.NET AJAX入门系列将会写关于ASP.NET AJAX一些控件的使用方法以及基础知识,其中部分文章为原创,也有一些文章是直接翻译自官方文档,本部分内容会不断更新。
目录
ASP.NET AJAX入门系列(1):概述
导读:作为本系列文章的开篇,简单介绍一下ASP.NET AJAX的概况及各个组成部分。
......
1、直接将页面内容存在变量中后输出:
StringBuilder IndexContentResult= new StringBuilder(); //存放输出页面的HTML
IndexContentResult.Append("<html>\n");
IndexContentResult.Append(&qu ......
/* from: http://www.techmango.com/blog/article/DotNet/Explore_Asp_net_postback_mechanism.htm */
__doPostBack作为在asp.net中一个很核心很重要的部分,我们有必要深入了解一下.
其实,__doPostBack是一个很简单的脚本函数.代码如下:
//__doPostBack<input type="hidden" name="__EVENTTARGET" id="__EVENTTA ......
效果图
Default.aspx页面的内容
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Verify._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www. ......
MVC2 框架安装完成以后我们就可以开始我们的 MVC之旅了,呵呵
本次学习内容:Route
首先 route 的中文意思就是我们常说的“路由”,确实这里也是这个意思,在我们MVC中已经不再使用 XX.aspx 来访问页面了,
所有页面的请求会通过route来解析找到对应的控制器(controller)里面对应的操作(action)来执行的。
mv ......