<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> New Document </TITLE> <META NAME="Generator" CONTENT="EditPlus"> <META NAME="Author" CONTENT=""> <META NAME="Keywords" CONTENT=""> <META NAME="Description" CONTENT=""> </HEAD><BODY><input type ="text" id ="txtPic" ><input type ="button" onclick ="showImage();" value ="查看"> <img id=img1 src="图片地址" onclick="javascript:img1toimg2();"><script> function showImage(){ img1.src="C:\\Documents and Settings\\Administrator\\桌面\\"+txtPic.value; } </script></BODY> </HTML> ------------------ 楼主测试同过。 C:\\Documents and Settings\\Administrator\\桌面\\---是文件目录,根据需要请指定.
什么呀!!我一定要用html的控件image 你用的是Web控件了
楼主,那里有WEB控件了?请指出来~~~~ -------------------------------------------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> New Document </TITLE> <META NAME="Generator" CONTENT="EditPlus"> <META NAME="Author" CONTENT=""> <META NAME="Keywords" CONTENT=""> <META NAME="Description" CONTENT=""> </HEAD><BODY><input type ="text" id ="txtPic" ><input type ="button" onclick ="showImage();" value ="查看"> <img id=img1 src="图片地址" onclick="javascript:img1toimg2();"><script> function showImage(){ img1.src="C:\\Documents and Settings\\Administrator\\桌面\\"+txtPic.value; } </script></BODY> </HTML> ------------------ 楼主测试同过。 C:\\Documents and Settings\\Administrator\\桌面\\---是文件目录,根据需要请指定.
function img1toimg2(){
img1.src="img2.jpg"
}
</script>
-------------
<form id="Form1" method="post" runat="server">
<asp:Image id="Image1" runat="server" ImageUrl="../admin/images/admin_top_open.gif"></asp:Image>
<asp:TextBox id="TextBox2" runat="server"></asp:TextBox>
<asp:Button id="Button2" runat="server" Text="Button"></asp:Button></P>
</FONT>
</form>
--------------------------------------
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;namespace aspnetc.test
{
/// <summary>
/// testCilentEvent 的摘要说明。
/// </summary>
public class testCilentEvent : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator1;
protected System.Web.UI.WebControls.Image Image1;
protected System.Web.UI.WebControls.Button Button2;
protected System.Web.UI.WebControls.TextBox TextBox2;
protected System.Web.UI.WebControls.Button btnTest;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面 } #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{ this.Button2.Click += new System.EventHandler(this.Button2_Click);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void Button2_Click(object sender, System.EventArgs e)
{
Image1.ImageUrl ="../admin/images/"+TextBox2.Text;
}
}
}
<script>
function img1toimg2(){
img1.src="img2.jpg"
}
</script>上面的不对吧!我有很多张图片,且图片名是在文本框中输入的
="../admin/images/"+TextBox2.Text;还要加扩展名吧,比如Image1.ImageUrl="="../admin/images/""+TextBox2.Text+".jpg"
toin((材娃))
----------------------
别这样说我,多不好意思,我就会这样的问题,难的就不行了~~~~楼主既然是ASP.NET那么用<asp:Image id="Image1" runat="server" ImageUrl="../admin/images/admin_top_open.gif"></asp:Image>服务器控件实现起来很方便的.
代码量很少的,建议楼主使用.html控件img是用于静态的地方是好一些的.
大家帮忙想一想!!!
大家帮忙想一想!!!
大家帮忙想一想!!!
大家帮忙想一想!!!
大家帮忙想一想!!!
大家帮忙想一想!!!
------------------------
楼主,把HTML的IMG删除了,加上
asp:Image id="Image1" runat="server" ImageUrl="../admin/images/admin_top_open.gif"></asp:Image>
不可以吗?
极度郁闷.......
大家帮忙想一想!!!
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD><BODY><input type ="text" id ="txtPic" ><input type ="button" onclick ="showImage();" value ="查看">
<img id=img1 src="图片地址" onclick="javascript:img1toimg2();"><script>
function showImage(){
img1.src="C:\\Documents and Settings\\Administrator\\桌面\\"+txtPic.value;
}
</script></BODY>
</HTML>
------------------
楼主测试同过。
C:\\Documents and Settings\\Administrator\\桌面\\---是文件目录,根据需要请指定.
你用的是Web控件了
--------------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD><BODY><input type ="text" id ="txtPic" ><input type ="button" onclick ="showImage();" value ="查看">
<img id=img1 src="图片地址" onclick="javascript:img1toimg2();"><script>
function showImage(){
img1.src="C:\\Documents and Settings\\Administrator\\桌面\\"+txtPic.value;
}
</script></BODY>
</HTML>
------------------
楼主测试同过。
C:\\Documents and Settings\\Administrator\\桌面\\---是文件目录,根据需要请指定.
我要在后台的.cs中完成.完成什么?我的img是后台动态生成的,如何动态生成?楼主,我太笨了,不理解什么意思,能否赐教?
在后台完成输入不同图片名出来不同图片的操作。
-------------------------------------------
id=img1 会变化吗?若不会,建议楼主在aspx中实现改功能;在aspx.cs中也可以完成该功能,那就是把
<script>
function showImage(){
img1.src="C:\\Documents and Settings\\Administrator\\桌面\\"+txtPic.value;
}
</script>
输出到客户端.在确认按钮中加入一个属性onclick = showImage(),以调用showImage();
-------------------------------------------------------------------
2.
我的img是后台动态生成的,如何动态生成?tc2.Text = "<IMG id=img1 height='127' width='100'>"我不明白楼主为什么不问题搞的这么复杂!要把图片的显示放在tc2.Text里.直接使用<asp:Image...>多方便!!
<script>
function showImage(){
img1.src="C:\\Documents and Settings\\Administrator\\桌面\\"+txtPic.value;
}
</script>
输出到客户端.在确认按钮中加入一个属性onclick = showImage(),以调用showImage();
_________________________________________________________________________________
我说了很多遍了,要在后台中完成,不要在前台定义函数。
又要在服务器的后续事件(服务端)中捕获先前生成的html图片控件?如果是,这本身就不是个好的想法
又要在服务器的后续事件(服务端)中捕获先前生成的html图片控件?如果是,这本身就不是个好的想法不好意思,少了两字