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(
相关文档:
+++ 修改Global.asax文件:
<%@ Application Language="C#" %>
<script runat="server">
void Application_Start(object sender, EventArgs e)
{
Application["count"] = 0;
}
void Application_End(object sender, EventArgs e)
{ }
void Application_Error(object sender, EventArgs ......
+++ Cookie01.aspx页面
++ 页面代码如下:
<asp:TextBox ID="TextBox1" runat="server" ForeColor="Red" Width="182px">Name</asp:TextBox>
<asp:Button ID="BtnCookie" runat="server" OnClick="BtnCookie_Click" Text="BtnCookie" /><br />
++ 后台代码如下:
protected void BtnCookie_Cl ......
参考 http://topic.csdn.net/t/20040510/19/3051316.html
开始
运行
dcomcnfg
组件服务一项中选择Dcom配置,找到Microsoft excel应用程序,察看属性
安全选项卡中,启动权限和访问权 ......
您可以使用HTTP模块,一个到ASP.NET HttpApplicationState类的扩展,在Global.asax编写代码强制ASP.NET在每一个页面请求时自动注入依赖的对象,就像在ASP.NET Web窗体应用程序中讨论的一样.
下列方法显示了一个合适的方法能够获取PreRequestHandlerExecute事件将它自己注入到ASP.NE ......
上次我们说到了 route 路由的功能,整个mvc运行过程:
Route(路由) --> Controller(控制器)-->action(方法)
这次我们要说的就是 controller 控制器 和 action:
控制器的作用就是:当一个 Request 来的时候,首先Route 解析 找到了 对应 控制器,控制器再根据 action 决定给我们返回什么样的内容。如:
代码 ......