首页上一页 1 下一页尾页 1 条记录 1/1页
ASP.NET从入门到精通51页例3.3问题
发表在ASP.NET图书答疑
2008-12-23
是否精华
是
否
版块置顶:
是
否
default3.aspx代码
<body>
<form id="form1" runat="server">
<div style="DISPLAY:inline;left:100px;POSITION:absolute;TOP:150px">
<asp:Button ID="btnOK" runat="server" OnClick="btnOK_Click" Text="确定" />
</div>
</form>
</body>
default3.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;
public partial class Default3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//打开图片文件,并存在文件流中
FileStream stream = new FileStream(Server.MapPath("picture.gif"), FileMode.Open);
long FileSize = stream.Length;//获取流的长度
byte[] Buffer = new byte[(int)FileSize];//定义一个二进制数组
stream.Read(Buffer, 0, (int)FileSize);//从流中读取字节块并将该数据写入给定缓冲区中
stream.Close();//关闭流
Response.BinaryWrite(Buffer);//将图片输出在页面上
}
protected void btnOK_Click(object sender, EventArgs e)
{
Response.Write("<script language=javascript>alert('hello world')</script>");//Write大小写敏感
}
}
上例运行时,可以正常输出图片,但本来设计好的网页中的按钮看不见了,为什么?
<body>
<form id="form1" runat="server">
<div style="DISPLAY:inline;left:100px;POSITION:absolute;TOP:150px">
<asp:Button ID="btnOK" runat="server" OnClick="btnOK_Click" Text="确定" />
</div>
</form>
</body>
default3.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;
public partial class Default3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//打开图片文件,并存在文件流中
FileStream stream = new FileStream(Server.MapPath("picture.gif"), FileMode.Open);
long FileSize = stream.Length;//获取流的长度
byte[] Buffer = new byte[(int)FileSize];//定义一个二进制数组
stream.Read(Buffer, 0, (int)FileSize);//从流中读取字节块并将该数据写入给定缓冲区中
stream.Close();//关闭流
Response.BinaryWrite(Buffer);//将图片输出在页面上
}
protected void btnOK_Click(object sender, EventArgs e)
{
Response.Write("<script language=javascript>alert('hello world')</script>");//Write大小写敏感
}
}
上例运行时,可以正常输出图片,但本来设计好的网页中的按钮看不见了,为什么?