日期:2014-05-19  浏览次数:20425 次

在线等待!有关于vs2003问题及输出


private   void   Page_Load(object   sender,   System.EventArgs   e)
{
//   在此处放置用户代码以初始化页面
if(   !   this.IsPostBack)
{
System.IO.DirectoryInfo   info=new   DirectoryInfo(@ "E:\c#示例 ");
foreach(System.IO.FileInfo   f   in   info.GetFiles( "*.cs "))
{
String   name=f.FullName;
long   size=f.Length;

string   s= "   <font   size=2   color=red> "+ " <input   type= 'button '       id= 'd '   onclick= 'alert( 'hello   world '); '     value= ' "+size.ToString()+ " '   </input> ";
Response.Write(s+ "&nbsp;&nbsp;&nbsp;&nbsp; "+name+ "&nbsp;&nbsp;&nbsp;&nbsp; "+f.CreationTime+ " <font> <br> <div   align= 'left '> <hr   color=blue   size=1   width= '50% '   > </div> ");
}


}
}

这段代码中的Button单击没有效果 ,我查看了HTML发现这样了一个问题,

  <font   size=2   color=red> <input   type= 'button '       id= 'd '   onclick= 'alert( 'hello   world '); '     value= '1334 '   </input> &nbsp;&nbsp;&nbsp;&nbsp;E:\c#示例\enum.cs&nbsp;&nbsp;&nbsp;&nbsp;2007-4-2   11:31:15 <font> <br> <div   align= 'left '> <hr   color=blue   size=1   width= '50% '   > </div>   <font   size=2   color=red> <input   type= 'button '       id= 'd '   onclick= 'alert( 'hello   world '); '     value= '370 '   </input> &nbsp;&nbsp;&nbsp;&nbsp;E:\c#示例\io.cs&nbsp;&nbsp;&nbsp;&nbsp;2007-4-2   11:50:12 <font> <br> <div   align= 'left '> <hr   color=blue   size=1   width= '50% '   > </div>
<!DOCTYPE   HTML   PUBLIC   "-//W3C//DTD   HTML   4.0   Transitional//EN "   >
<HTML>
<HEAD>
<title> WebForm1 </title>
<meta   name= "GENERATOR "   Content= "Microsoft   Visual   Studio   .NET   7.1 ">
<meta   name= "CODE_LANGUAGE "   Content= "C# ">
<meta   name= "vs_defaultClientScript "   content= "JavaScript ">
<meta   name= "vs_targetSchema "   content= "http://schemas.microsoft.com/intellisense/ie5 ">
</HEAD>
<body   MS_POSITIONING= "GridLayout ">
<form   name= "_ctl0 "   method= "post "   action= "WebForm1.aspx "   id= "_ctl0 ">
<input   type= "hidden "   name= "__VIEWSTATE "   value= "dDwtNjU0MzcyMTk1Ozs+Q9Sem0vH0+DOKc3WsZdO/t2PrPE= "   />


</form>
<FONT   face= "宋体 "> </FONT>
</body>
</HTML>
为什么显示是这样的?

------解决方案--------------------
按照你的做法是这样很合理啊, 你不要使用write, 你可以在适当的位置放个server div , 后人再吧html赋给div.
------解决方案--------------------
Response.Write肯定是不