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

Asp.Net Master模板页的控件和属性

 内容页访问MasterPage中的控件,有两种解决方案:
一、是用弱类型访问
    使用 FindControl 方法获取模板页的控件
    ((Label)Master.FindControl("Label1")).Text = "xxx";
  
二、给模板页添加属性来使用强类型访问(推荐)
    模板页定义;
    //属性
    private string x;
    public string X
    {
        get { return this.x; }
        set { this.x = value; }
    }
    //控件的属性以属性的形式公开给内容页
    public string LabelCaption
    {
        get { return this.Label1.Text; }
        set { this.Label1.Text = value; }
    }
    模板页使用属性的时候,内容页要访问的话,必须在模板页中加入一条指令,如:
    <%@ MasterType VirtualPath="~/MasterPage.master" %>
    //使用Master关键字获取模板页的信息
    Master.TextBoxValue = "xxx";
    Master.LabelCaption= "yyy";
    Master.X = "zzz";
如果不是用<%@ MasterType VirtualPath="~/MasterPage.master" %>将会编译错误,也不会出想智能提示


相关文档:

asp.net上传文件格式限制

if(MyFile.PostedFile.ContentType   !=   "image/gif"    
  &&   MyFile.PostedFile.ContentType   !=   "image/jpg"    
  &&   MyFile.PostedFile.ContentType   !=   "image/pjpeg"    
  && &n ......

Asp.net技巧:gridview获取当前行索引的方法

在用GridView控件时,我们经常会碰到获取当前行的索引,通过索引进行许多操作。例如,可以获得当前行某一个控件元素;设置某一元素的值等等。
下面结合实例介绍几种获得GridView当前行索引值的方法。
实例:
① 目的:获取GridView中RowCommand的当前索引行。
② 前台页面:在GridView中添加一模版列,里面添加一个Link ......

asp.net 部署数据库、开始菜单、桌面快捷方式实例


//部署桌面快捷方式*******************#region//部署桌面快捷方式*******************
     StreamWriter sw2=System.IO.File.CreateText(Context.Parameters["des"].ToString()+"WebSetupTest.url");
     stateSaver.Add("DeskQuick",Context.Parameters["des"].ToString() ......

ASP.NET中cookie的几种创建和访问方法

来源:草根站长
Cookie (HttpCookie的实例)提供了一种在 Web 应用程序中存储用户特定信息的方法。例如,当用户访问您的站点时,您可以使用Cookie 存储用户首选项或其他信息。当该用户再次访问您的网站时,应用程序便可以检索以前存储的信息。
ASP.NET中的cookie:创建Cookie方法 (1)
Response.Cookies["userName"].Valu ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号