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 ......
使用flash开发的SWFUpload上传组件有很多好处,支持进度条是其中一种好处,下面是asp.net封装SWFUpload下载地址:
效果图:
如果直接拷贝SWFUpload文件夹到你的项目
记得必须引用SWFUploadAPI.dll
点击此处下载:SWFUpload.rar
文章来自学IT网:http://www.xueit.com/html/2010-05/21-12561321642010518215213640 ......
第一步 掌握一门.NET面向对象语言,C#或VB.NET 我强烈反对在没系统学过一门面向对象(OO)语言的前提下去学ASP.NET。 ASP.NET是一个全面向对象的技术,不懂OO,那绝对学不下去!
第二步 对.NET Framework类库有一定的了解 可以通过开发Windows Form应用程序来学习.NET Framework。ASP.NET是建构在.NET Framework之上的 ......
如有页面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 ......
前面我们说过了 控制器(controller) 和方法(action)
本次要说的就是 View以及和控制器(controller)、方法(action)之间的关系;
大家都知道 MVC中的 V 就是View 的意思,就是 呈现给用户的界面,以往的asp.net项目中叫 webform,以前做asp.net的时候就是在工具箱里面拖控件出来,
然后简单的排版一下就ok了,大多数用的服 ......