【asp.net的cms 核心代码篇】教程文章相关的互联网学习教程文章

Global.asax的Application_BeginRequest实现url重写无后缀的代码

利用Global.asax的Application_BeginRequest 实现url 重写 无后缀 代码如下:<%@ Application Language="C#" %> <script RunAt="server"> void Application_BeginRequest(object sender, EventArgs e) { string oldUrl = System.Web.HttpContext.Current.Request.RawUrl; //获取初始url //~/123.aspx → ~/Index.aspx?id=123 Regex reg = new Regex(@"^\/\d+\.html"); if (reg.IsMatch(oldUrl)) { string id = reg.Match(oldUrl).T...

silverlight用webclient大文件上传的实例代码

客户端: 代码如下: /// <summary> /// 写入数据到流中 /// </summary> /// <param name="url"></param> /// <param name="callback"></param> public async static Task<bool> Write(string url, Stream clientStream) { if (clientStream.Length > 25*1024*1024) url += "&t=1"; // 表示上传大文件 try { Up(url, clientStream); ...

TreeView无刷新获取text及value实现代码

前台代码: 代码如下:<html xmlns="http://www.w3.org/1999/xhtml"><head id="Head1" runat="server"> <title></title> <style type="text/css"> #middle{ top:0; left:0;background-color:#fff; position:absolute; z-index:2; filter:alpha(opacity=60); display:none;} #showTree{ width:300px; height:200px; position:fixed; z-index:2; display:none; border:1px solid red;} </style> <script type="text...

ASP.NET 防止按钮多次提交核心实现代码

代码如下:<asp:Button ID="btnSubmit" runat="server" UseSubmitBehavior="false" OnClientClick="this.disabled=true; " Text="Submit" OnClick="Button1_Click" /> 主要添加 代码如下:UseSubmitBehavior="false" OnClientClick="this.disabled=true; "2个属性 就可以防止多次提交 顺便求助一个问题 这样设置之后,Button1_Click事件执行完成这个禁用属性会变为false,也就是后台事件执行完成之后又可以点击了,现在解决的问题就...

asp.net直接Response输出WML页面示例代码

代码如下:protected void Page_Load(object sender, EventArgs e) { Response.ContentType = "text/vnd.wap.wml"; StringBuilder builder = new StringBuilder(); builder.AppendLine("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"); builder.AppendLine("<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.2//EN\" \"http://www.wapforum.org/DTD/wml12.dtd\">"); builder.AppendLine("<wml>"); builder.AppendLine("<head>"); bu...

ASP.NET打开新页面而不关闭原来的页面 实例代码

代码如下:Respose.Write("<script language='javascript'>window.open('"+ url +"');</script>"); (打开简洁窗口):Respose.Write("<script language='javascript'>window.open('" + url + "','','resizable=1,scrollbars=0,status=1,menubar=no,toolbar=no,location=no, menu=no');</script>");1. Response.Redirect("XXX.aspx",true)——直接转向新的页面,原窗口被代替;2. Response.Writ...

在子页中隐藏模板页中的div示例代码

需求如下: 1.模板页右边包含了一个登陆div,想让没登陆的时候这个div显示,登陆后该div隐藏 2.显示一个欢迎用户的div,主要是想通过javascript来隐藏 注意:模板页里是不能使用RegisterClientScriptBlock注册和执行javascrip的, 所以javascript的注册和执行放在page页中来实现了 Main.master模板页里的内容 代码如下:<!--登录小div--> <div class="loginDiv"> <div class="LoginDivTitle"> 会员登录 </div> <table class="loginTable...

ASP.NET MVC 从IHttp到页面输出的实例代码

代码如下:MVCHandler : IHttpHandlervoid IHttpHandler.ProcessRequest(HttpContext httpContext){ this.ProcessRequest(httpContext);} protected virtual void ProcessRequest(HttpContext httpContext){ HttpContextBase base2 = new HttpContextWrapper(httpContext); this.ProcessRequest(base2);} protected internal virtual void ProcessRequest(HttpContextBase httpContext){ IController controller; IC...

Asp.Net获取网站截图的实例代码

代码如下:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace WindowsFormsApplication1{ public partial class Form1 : Form { private WebBrowser _webBrowser; public Form1() { InitializeComponent(); } public void GetThumbNail(string url...

asp.net获取服务器基本信息的方法代码

代码如下://Server Name"Server Name": Server.MachineName"Server Domain": Request.ServerVariables["Server_Name"]"Server Port": Request.ServerVariables["Server_Port"]"Web Server Version": Request.ServerVariables["Server_SoftWare"]//Path"Virtual Request Path": Request.FilePath"Physical Request Path": Request.PhysicalPath"Virtual Application Root Path": Request.ApplicationPath"Physical Application Root...

Asp.net图片上传实现预览效果的简单代码

在页面上放入一个上传控件和一个图片控件. 代码如下: <asp:FileUpload ID="FileUpload1" runat="server" onpropertychange="show(this.value)"/> <asp:Image ID="Image1" runat="server" /> 在上传控件中写onpropertychange="show(this.value)"事件并调用js中的show函数并将自身的参数传进js. 代码如下: <script type="text/javascript"> function show(id) ...{ document.getElementById("Image1").src...

C#.NET发送邮件的实例代码

代码如下:using System;using System.Collections.Generic;using System.Text;using System.Net.Mail;using System.Net;namespace MyQuery.Utils{ /// <summary> /// 封装邮件处理 /// by 贾世义 2011-6-3 /// </summary> public static class MailHelper { private static string smtpHost = null; private static int smptPort = 25; private static bool smtpIsUserCredentials = false...

asp.net 数据绑定的实例代码

代码如下:public partial class _Default : System.Web.UI.Page{ protected string title="大家好"; //前台代码<title><%#title %></title> protected void Page_Load(object sender, EventArgs e) { DataSet ds = new DataSet(); string sql = ConfigurationManager.ConnectionStrings["strsql"].ConnectionString; using (SqlConnection sqlCnn=new SqlConnection(sql)) { ...

ASP.NET动态生成静态页面的实例代码

最近突然想把项目中新闻管理模块做成静态页,在网上找到很多很好的文章,在这里记录一下,现在只是实现静态页面的生成并没有实现分页功能。其主要原理就是读取数据库的数据然后替换掉静态模板页的内容。首先制作一个模板页,暂时命名为template.htm,示例代码如下:<!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/199...

DataAdapter执行批量更新的实例代码

在以前版本的 ADO.NET 中,使用 DataSet 中的更改来更新数据库时,DataAdapter 的 Update 方法每次更新数据库的一行。因为该方法循环访问指定 DataTable 中的行,所以,会检查每个 DataRow,确定是否已修改。如果该行已修改,将根据该行的 RowState 属性值调用相应的 UpdateCommand、InsertCommand 或 DeleteCommand。每一次行更新都涉及网络与数据库之间的双向数据传输。 在 ADO.NET 2.0 中,DataAdapter 公开了 UpdateBatchSi...