不能
没有你这种格式,因为src 是一个路径
没有你这种格式,因为src 是一个路径
解决方案 »
- GridView的DataKeyNames有值,但DataKeys却无值,太不解了
- linkbutton控件失效!
- Microsoft Server2008系统下 WEB服务器 和 SQL(2008)服务器分开部署,如何实现数据库访问?
- 关于名字空间的问题
- 学.net的程序员如何向底层发展
- web应用程序调用web services出错(xp系统)
- 高分求解关于DirectoryServices的问题
- 终于碰到一个不菜的问题(<%#Container.DataItem%>),可是没有分了:(
- 如何自动记住登录名?
- 请问有没有方法 定时的把WEB服务器上的一个.txt文件发到一个指定的邮箱中
- 我想问一下,输出excel的功能完成后,发布的时候,服务器需要装office吗?
- "操作必须使用一个可更新的查询。"这是什么毛病?
在要放置四个图形的地方放置一个脚本标签:
<script src="WebForm5.aspx?ImgID=<%=变量%>"></script>然后在WebForm5.aspx中输入四个图形的脚本,例如:
Page.Response.Clear();
Page.Response.AddHeader( "Content-Type", "text/html" );
string str= "document.write(\"<img src='1.gif'>\")";
string str= "document.write(\"<img src='2.gif'>\")";
string str= "document.write(\"<img src='3.gif'>\")";
string str= "document.write(\"<img src='4.gif'>\")";
Page.Response.Output.Write(str);
Page.Response.End();
<img id ="Image1"
Src=
runat=server/>
:)
我只是想以另外一种方式问问题
哎,我老师出的题目,我只能照做
非得用他所谓的组件,DLL什么技术
而我都。
当然可以你可以在你的组件中,判断数据源,这个可以由你自己定义一个结构
按照你的有求,一个字符串的数据就行了
用来保存要显示图片的url然后在这个组件的DataBind()方法中根据数据源的数据来创建<img>显示图片a simple example:
class MyImg : System.Web.UI.WebControls.WebControl
{
public MyImg() : base(HtmlTextWriterTag.Table)
{}
private string[] _dataSource = null;
public overrid object DataSource
{
get{
return _dataSource;
}
set{
string[] temp = value as (string[]);
if( temp != null )
_dataSource = temp;
else
throw new Exception("invalid value!");
}
} protected override void OnPreRender( EventArgs e )
{
if( _dataSource != null && _dataSource.Length != 0 )
{
foreach( string s in _dataSource )
{
TableRow row = new TableRow();
this.Controls.Add( row );
TableCell cell = new TableCell();
row.Cells.Add( cell );
System.Web.UI.HtmlControls.HtmlImage img = new System.Web.UI.HtmlControls.HtmlImage();
img.Src = s;
cell.Controls.Add( img );
}
}
}
}这里只是简单的写了一下
要实现更强大的功能,可以参考msdn的如何编写服务器控件