Default..aspx
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
Default..aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using sqlpublic;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string url = Server.MapPath("~/default.html");
if (File.Exists(url))
File.Delete(url);
Response.Filter = new ResponseFilter(Response.Filter, Server.MapPath("~/Default.html"));
}
}
ResponseFilter.cs
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace sqlpublic
{
public class ResponseFilter : Stream
{
private Stream m_sink;
private long m_position;
privat ......
#region ÓòÃû°ó¶¨·½·¨
public static void AddHostHeader(int siteid, string ip, int port, string domain)//Ôö¼ÓÖ÷»úÍ·£¨Õ¾µã±àºÅ.ip.¶Ë¿Ú.ÓòÃû£©
{
DirectoryEntry site = new DirectoryEntry("IIS://localhost/W3SVC/" + siteid);
PropertyValueCollection serverBindings = site.Properties["ServerBindings"];
string headerStr = string.Format("{0}:{1}:{2}", ip, port, domain);
if (!serverBindings.Contains(headerStr))
{
serverBindings.Add(headerStr);
}
site.CommitChanges();
}
#endregion
#region ɾ³ýÖ÷»úÍ·
public static void Delete ......
Ò»¡¢
Js
ÉèÖÃĬÈÏ°´Å¥
function
document.onkeydown()
{
var
e=event
.srcElement;
if
(event
.keyCode==13)
{
document.getElementById("btnSearch"
).focus();
return
true
;
}
}
¶þ¡¢
ÔÚ
Form
±êÇ©ÖÐÉèÖÃ
defaultbutton
ÊôÐÔ
<
form
id
="form1"
runat
="server"
defaultbutton
="
ĬÈÏ°´Å¥
ID">
Èý¡¢
DefaultButton.js
ÎļþÄÚÈÝ
&nb ......
µ÷ÓÃ
ÑéÖ¤Â룺<input type="text" id="txtValidate" style="border: solid 1px #9B9B9B; width: 85px;
height: 17px;" /> <img src="Rnd.aspx" mce_src="Rnd.aspx" style="width: 58px; height: 17px;
border: solid 1px #9B9B9B" align="absmiddle" />
ºǫ́ʵÏÖ
Rnd.aspx.cs
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Drawing;
using System.Drawing.Imaging;
public partial class Rnd : System.Web.UI.Page
{
private int codeLen = 5;//Ëæ»úÏÔʾ×Ö·û¸öÊý
private int fineness = 100;//ͼƬÇåÎú¶È
private int imgWidth = 65;//ͼƬ¿í¶È
private int imgHeight = 20;//ͼƬ¸ß¶È
private string fontFamily = "Roman";//×ÖÌåÃû³Æ
private int fontSize = 12; //×ÖÌå´óС
private ......
asp.netÖÐÈçºÎ½øÐÐurlÖØд£¬½ñÌìÑо¿ÁËÒ»ÌìÕâ¸öÎÊÌâ
ÏëʵÏÖÖîÈ磺http://www.51cto.com/2008/2/2
http://www.51cto.com/default.html
µÈÕâÖÖurl
µ±È»£¬³ÌÐòÖ±½ÓÉú³É¾²Ì¬Ò³Ãæ¿ÉÒÔʵÏÖµÄ
µ«ÊÇÄÇÑùÒªÉú³ÉºÜ¶àÕâÖÖÒ³ÃæÒÔ¼°Îļþ¼Ð
¶øÇÒÔÚÊý¾ÝÁ¿´óµÄÇé¿öÏÂÉú³ÉÊǺÜÀË·Ñʱ¼äµÄ
ÔÚÕâÖÖÇé¿öϾÍҪʵÏÖurlÖØдÁË£¬µ±È»¾ÍºÜ¶àÖÖ·½·¨
ÏÂÃæ½éÉܵÄÊÇ΢ÈíµÄURLRewriter·½·¨
1.Ê×ÏÈÏÂÔØURLRewriter.dll£¬ÏÂÔØÖ®ºóÖ±½Ó¸´ÖƵ½ÄãµÄÍøÕ¾µÄbinĿ¼ÖÐ
2.ÅäÖÃÄãµÄweb.configÎļþ
ÔÚ<configuration>½ÚµãϼÓ
<configSections>
<section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter" />
</configSections>
<RewriterConfig>
<Rules>
<!--Ò»ÏÂÈý¸öÊÇÎÒ×Ô¼ºÐ´µÄ²âÊԵģ¬µ±È»Äã¿ÉÒÔдºÜ¶à¸ö -->
<!--Õâ¸öÊÇ°Ñhttp://localhost:2001/default.aspx?id=1 Éú³Éhttp://localhost:2001/d1.aspx ÕâÖ ......
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection conn;
SqlCommand cmd1, cmd2;
SqlTransaction tra;
conn = new SqlConnection("server=.;database=test;uid=sa;pwd=123");
conn.Open();
tra = conn.BeginTransaction();//¿ªÊ¼ÊÂÎñ
cmd1 = new SqlCommand("update Test set StuName='¼Ñ¶ù' where StuScore=111", conn);
cmd2 = new SqlCommand("update Test set StuName='fdsafdsafdsfdsafsfsdadsadsadfsafsfsfdf' where StuScore=222", conn);
try
{
cmd1.ExecuteNonQuery();//´Ë¾ä¿ÉÒԳɹ¦Ö´ÐÐ
cmd2.ExecuteNonQuery();//´Ë¾ä¹ÊÒâÈÃÆäÖ´ÐÐʧ°Ü
tra.Commit();//ÎÞÒì³££¬Ìá½»ÊÂÎñ(Á½¾äÖ´Ðж¼ÓÐЧ)
Response.Write("<mce:script type="text/javascript"><!--
alert('Ö´Ðгɹ¦')
// --></mce:script>");
}
catch
{
tra.Rollback();//³öÏÖÒì³££¬»Ø¹öÊÂÎñ(Á½¾äÖ´Ðж¼ÎÞЧ)
Response.Write("<mce:script type="t ......