2013年9月10日

.net中的路径问题

摘要: 1、Server.MapPath("/") 应用程序根目录所在的位置 如 C:\Inetpub\wwwroot\2、Server.MapPath("./") 表示所在页面的当前目录注:等价于Server.MapPath("") 返回 Server.MapPath("") 所在页面的物理文件路径3、Server.MapPath("../")表示上一级目录4、Server.MapPath("~/")表示当前应用级程序的目录,如果是根目录,就是根目录,如果是虚拟目录,就是虚拟目录所 阅读全文

posted @ 2013-09-10 19:20 YoungPop_Chen 阅读(227) 评论(0) 推荐(0) 编辑

Response.Redirect 打开新窗口的两种方法

摘要: 一般情况下,Response.Redirect 方法是在服务器端进行转向,因此,除非使用 Response.Write("") 方法外,是不能在新窗口打开所指定的 URL 地址的。但是,如果仔细分析一下,如果设置 form 元素的 target 属性,还是有办法打开新窗口的。下面就是可以采用的两种方法。方法一:在服务器端设置 target 属性,这个方法也非常适用于客户端不支持脚本的情况。代码如下:办法二:采用客户端脚本的方法设置 target 属性。代码如下:上面两种方法中的 target 属性可以采用任何合法的名称,但要注意,如果相同名称的窗口已经打开,则新窗口会在已经 阅读全文

posted @ 2013-09-10 19:19 YoungPop_Chen 阅读(206) 评论(0) 推荐(0) 编辑

.net图片路径问题高手帮忙啊~

摘要: 1. 常量中有换行符,解决:Server.MapPath("~image\")改为:Server.MapPath("~image\\") //就是 \ 改为 \\2.图片路径问题,将string sql = "insert into s....... 这句修改为:string sql = "insert into shangpin (image) values('image/" + FileUpload1.FileName + "')"; 阅读全文

posted @ 2013-09-10 19:17 YoungPop_Chen 阅读(205) 评论(0) 推荐(0) 编辑

GRIDVIEW FINDCONTROL的使用

摘要: 1 GRIDVIEW FINDCONTROL的使用 2 Gridview FindControl的使用 3 //先看看FindControl的源码 4 protected virtual Control FindControl(string id, int pathOffset) { string str; this.EnsureChildControls(); if (!this.flags[0x80]) { Control namingContainer = this.NamingContainer; if (namingContainer != null) { return n... 阅读全文

posted @ 2013-09-10 19:13 YoungPop_Chen 阅读(734) 评论(0) 推荐(0) 编辑

如何验证gridview控件的编辑行?如何获得gridview模板列<ItemTemplate/>中Label值?

摘要: 1.验证gridview控件的编辑行:原来datagrid中在ItemDatabound中//判断是否是编辑项if(e.Item.ItemType==ListItemType.EditItem){//添加验证事件}但现在的RowDataBound没有表示编辑项了,不知怎么表示?2.获得gridview模板列中Label值由于采用编辑模板,要后台获得'>lblClass值,根据控件label值显示不同的值,在RowDataBound怎么获取?1 if ((e.Row.RowState & DataControlRowState.Edit) != 0)2 if (e.Row. 阅读全文

posted @ 2013-09-10 19:11 YoungPop_Chen 阅读(530) 评论(0) 推荐(0) 编辑

在Repeater的HeaderTemplate和FooterTemplate模板中寻找控件FindControl

摘要: 在Repeater的ItemTemplate模板中的控件,我们可以用Items属性来遍历行并用FindControl进行寻找,如下所示:在Repeater的Item Command事件下下遍历: for(int i=0;i '> 【下边代码示例寻找Label1和Label3】【程序代码】//在HeaderTemplate中寻找Label1,默认为第0个string s=((Label)Repeater1.Controls[0].FindControl("Label1")).Text;//在FooterTemplate中寻找Label2,默认为最后一... 阅读全文

posted @ 2013-09-10 19:06 YoungPop_Chen 阅读(298) 评论(0) 推荐(0) 编辑

在GridView中使用FindControl(2)

摘要: 最近项目中用到FindControl和GridView,整理了一下几种使用方法,留作资料。 1、在选择(SelectedIndexChanged)事件中使用 //获得被选择行的TextBox1 protected void gv1_SelectedIndexChanged(object sender, EventArgs e) { //Control c = this.gv1.Rows[this.gv1.SelectedIndex].FindControl("TextBox1"); //TextBox tb = ... 阅读全文

posted @ 2013-09-10 19:04 YoungPop_Chen 阅读(171) 评论(0) 推荐(0) 编辑

构造函数(C# 编程指南)

摘要: http://msdn.microsoft.com/zh-cn/library/ms173115.aspx 阅读全文

posted @ 2013-09-10 19:00 YoungPop_Chen 阅读(94) 评论(0) 推荐(0) 编辑

导航