用vs2005写一个程序要求用1个按钮和一个图片控件,按一下按钮,图片换一张 30
usingSystem;usingSystem.Data;usingSystem.Configuration;usingSystem.Web;usingSystem.We...
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;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.Write("Load");
}
protected void Button1_Click(object sender, EventArgs e)
{
Image1.ImageUrl = Server.Mappath("~/show_files/dh_1.jpg");
}
}
提示信息是当前上下文中不存在Image1,提示我的确添加了Image1这个控件
目标是将控件的URL改成~/show_files/dh_1.jpg,原来Image1 的属性是~/show_files/dh_2.jpg
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!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/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click"
Text="换图片" />
<asp:Image ID="Image1" runat="server" Height="60px" ImageUrl="~/show_files/dh_1.jpg"
Width="79px" />
<br />
</div>
</form>
</body>
</html>
这是一个联系就是让用.net处理的~~ 展开
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;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.Write("Load");
}
protected void Button1_Click(object sender, EventArgs e)
{
Image1.ImageUrl = Server.Mappath("~/show_files/dh_1.jpg");
}
}
提示信息是当前上下文中不存在Image1,提示我的确添加了Image1这个控件
目标是将控件的URL改成~/show_files/dh_1.jpg,原来Image1 的属性是~/show_files/dh_2.jpg
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!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/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click"
Text="换图片" />
<asp:Image ID="Image1" runat="server" Height="60px" ImageUrl="~/show_files/dh_1.jpg"
Width="79px" />
<br />
</div>
</form>
</body>
</html>
这是一个联系就是让用.net处理的~~ 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询