Asp.net常用的51个代码(非常实用)
Asp.net常用的51个代码(非常实用)
1.//弹出对话框.点击转向指定页面
CODE:
Response.Write("<script>window.alert('该会员没有提交申请,请重新提交!')</script>");
Response.Write("<script>window.location ='http://www.51aspx.com/bizpulic/upmeb.aspx'</script>");
2.//弹出对话框
CODE:
Response.Write("<script language='javascript'>alert('产品添加成功!')</script >");
3.//删除文件
CODE:
string filename ="20059595157517.jpg";
pub.util.DeleteFile(HttpContext.Current.Server.MapPath("../file/")+filename);
4.//绑定下拉列表框datalist
CODE:
System.Data.DataView dv=conn.Exec_ex("select -1 as code,'请选择经营模式' as content from dealin union select code,content from dealin");
this.dealincode.DataSource=dv;
this.dealincode.DataTextField="content";
this.dealincode.DataValueField="code";
this.dealincode.DataBind();
this.dealincode.Items.FindByValue(dv[0]["dealincode"].ToString()).Selected=true;
5.//时间去秒显示
[复制到剪贴板]
CODE:
<%# System.DateTime.Parse(DataBinder.Eval(Container.DataItem,"begtime").ToString()).ToShortDateString()%>
6.//标题带链接
[复制到剪贴板]
CODE:
<%# "<a class=\"12c\" target=\"_blank\" href=\"http://www.51aspx/CV/_"+DataBinder.Eval(Container.DataItem,"procode")+".html\">"+ DataBinder.Eval(Container.DataItem,"proname")+"</a>"%>
7.//修改转向
[复制到剪贴板]
CODE:
<%# "<A href=\"editpushpro.aspx?id="+DataBinder.Eval(Container.DataItem,"code")+"\">"+"修改"+"</A>"%>
8.//弹出确定按钮
[复制到剪贴板]
CODE:
<%# "<A
相关文档:
ASP.Net邮件发送类
本文转自:http://www.pcstu.com/program/Asp_net/sl/20070706/52523.html
说明:本文没有测试,但看起来似乎不能用于发送附件,如要发送附件,可参考:http://blog.csdn.net/lff642/archive/2008/07/15/2654346.aspx
using System;
using System.Text;
using System.IO;
using System.Net;
using ......
ASP.NET C# 生成静态页面简单方法
//源码是替换掉模板中的特征字符
string mbPath = Server.MapPath("template.html");
Encoding cod ......
例子:
using system.web.caching
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<html>
<script language="C#" runat="server">
void Page_Load(Object Src, EventArgs E) {
DataView Source;
// Retrieve the DataView obj ......
<% @ Page Language = " C# " %>
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
< script runat ="server" >
System.Data.DataView Crea ......
今天,看到PETSHOP4.0里的WEB.CONFIG对数据库连接字符串加密,所以特意学习并记录下来。
.net 提供了 System.Configuration.RsaProtectedConfigurationProvider 。
首先配置WEB.CONFIG
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
< ......