易截截图软件、单文件、免安装、纯绿色、仅160KB

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页面传值_第六篇_Cookie

+++ 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 ......

asp.net 打印 拒绝访问

参考 http://topic.csdn.net/t/20040510/19/3051316.html
      开始
      运行
      dcomcnfg
      组件服务一项中选择Dcom配置,找到Microsoft   excel应用程序,察看属性
      安全选项卡中,启动权限和访问权 ......

探索Asp.net的Postback机制

/* 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 ......

asp.net验证码制作实例代码

效果图
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. ......

ASP.NET防后退

如有页面Admin,则在其cs文件中写如下代码:
protected void Page_Load(object sender, EventArgs e)
{
Response.AddHeader("Cache-Control", "no-cache");
Response.Expires = -1;
Response.Cache.SetNoStore();
Response.AddHeader("Pragma", "no-cache");
Response ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号