ASP.NetÉú³É¾²Ì¬HTMLÒ³
ASP.NetÉú³É¾²Ì¬HTMLÒ³!
»·¾³:Microsoft .NET Framework SDK v1.1
OS:Windows Server 2003 ÖÐÎÄ°æ
ASP.NetÉú³É¾²Ì¬HTMLÒ³
ÔÚAspÖÐʵÏÖµÄÉú³É¾²Ì¬Ò³Óõ½µÄFileSystemObject¶ÔÏó!
ÔÚ.NetÖÐÉæ¼°´ËÀà²Ù×÷µÄÊÇSystem.IO
ÒÔÏÂÊdzÌÐò´úÂë ×¢:´Ë´úÂë·ÇÔ´´!²Î¿¼±ðÈË´úÂë
//Éú³ÉHTMLÒ³
public static bool WriteFile(string strText,string strContent,string strAuthor)
{
string path = HttpContext.Current.Server.MapPath("/news/");
Encoding code = Encoding.GetEncoding("gb2312");
// ¶ÁÈ¡Ä£°åÎļþ
string temp = HttpContext.Current.Server.MapPath("/news/text.html");
StreamReader sr=null;
StreamWriter sw=null;
string str="";
try
{
sr = new StreamReader(temp, code);
str = sr.ReadToEnd(); // ¶ÁÈ¡Îļþ
}
catch(Exception exp)
{
HttpContext.Current.Response.Write(exp.Message);
HttpContext.Current.Response.End();
sr.Close();
}
string htmlfilename=DateTime.Now.ToString("yyyyMMddHHmmss")+".html";
// Ìæ»»ÄÚÈÝ
// Õâʱ,Ä£°åÎļþÒѾ¶ÁÈëµ½Ãû³ÆΪstrµÄ±äÁ¿ÖÐÁË
str =str.Replace("ShowArticle",strText); //Ä£°åÒ³ÖеÄShowArticle
str = str.Replace("biaoti",strText);
str = str.Replace("content",strContent);
str = str.Replace("author",strAuthor);
// дÎļþ
try
{
sw = new StreamWriter(path + htmlfilename , false, code);
sw.Write(str);
sw.Flush();
}
catch(Exception ex)
{
HttpContext.Current.Response.Write(ex.Message);
HttpContext.Current.Response.End();
}
finally
{
&nbs
Ïà¹ØÎĵµ£º
ÌõÐÎÂëÊÇÆù½ñΪֹ×á¢ÊµÓõÄÒ»ÖÖ×Ô¶¯Ê¶±ð¼¼Êõ¡£ÌõÐÎÂë¼¼Êõ¾ßÓÐÒÔϼ¸¸ö·½ÃæµÄÓŵã
¡¡¡¡A£®ÊäÈëËٶȿ죺Óë¼üÅÌÊäÈëÏà±È£¬ÌõÐÎÂëÊäÈëµÄËÙ¶ÈÊǼüÅÌÊäÈëµÄ5±¶£¬²¢ÇÒÄÜʵÏÖ“¼´Ê±Êý¾ÝÊäÈ딡£
¡¡¡¡B£®¿É¿¿ÐԸߣº¼üÅÌÊäÈëÊý¾Ý³ö´íÂÊΪÈý°Ù·ÖÖ®Ò»£¬ÀûÓùâѧ×Ö·ûʶ±ð¼¼Êõ³ö´íÂÊΪÍò·ÖÖ®Ò»£¬¶ø²ÉÓÃÌõÐÎÂë¼¼ÊõÎóÂëÂʵ ......
дͼƬc:\1.jpgµ½±ícinfoÖÐ
private static void AddCinfo()
{
string strSql = "insert into cinfo (srvtitle,csttitle,introduction,logo) values
(@srvtitle,@csttitle,@introduction,@logo)";
S ......
ÏÈ¿´¿´ASP.NETÒ³ÃæˢеÄʵÏÖ·½·¨£º
µÚÒ»£º
private void Button1_Click( object sender, System.EventArgs e ) { Response.Redirect( Request.Url.ToString( ) ); } µÚ¶þ£º
private void Button2_Click( object sender, System.EventArgs e ) { Response.Write( " < script language=javascript>window.locatio ......
ÔÚASP.NETÖÐ,ÎÒÃÇ¿ÉÒÔÓÃÏÂÃæµÄ·½·¨ÊµÏÖ´ÓÊý¾Ý¿âÖжÁȡͼƬ²¢ÏÔʾÔÚÒ³ÃæÉÏ,·½·¨ÈçÏÂ:
SqlConnection conn=new SqlConnection(ConfigurationSettings.AppSettings["ConnStr"]);
String sql="SELECT image from append where id='" + strID + "'";
&n ......
1.TextBox txt=(TextBox)PreviousPage.FindControl("TextBox1");
2.ÔÚÒ³Ãæ×¢²áͶµÝÒ³µÄÊôÐÔ
<%@ PreviousPageType VirtualPath="crouspostPage.aspx" %>
ÔÚcrouspostPage.aspxµÄ´úÂëÒþ²ØÀàÖÐÌí¼Ó
public TextBox TextBox1
{
get(return _textbox);
}
ÔÚÒ³ÃæÖÐResponse.Write(PreviousPage. ......