错误:不包含脚本里的函数

dyiajure 2009-07-02 02:36:58
<Columns>
<asp:TemplateColumn HeaderText="照片">
<ItemTemplate>
<asp:Image Runat="server" ID="Image1" OnLoad="scalePhoto(Image1,200,400)"
ImageUrl='<%# FormatURL(DataBinder.Eval(Container.DataItem, "ID")) %>' />
</ItemTemplate>
</asp:TemplateColumn>
</Columns>

搞不明白了
...全文
42 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
ouyang3857116 2009-07-06
  • 打赏
  • 举报
回复
Sorry,改为OnLoad="scalePhoto("Image1",200,400)"
ouyang3857116 2009-07-06
  • 打赏
  • 举报
回复
OnLoad="scalePhoto(Image1,200,400)"
改为
OnLoad="scalePhoto(this,200,400)"试试
dyiajure 2009-07-03
  • 打赏
  • 举报
回复

<script language= "JavaScript " type= "text/javascript ">
function scalePhoto(imgId,width,height){
var img = document.getElementById(imgId);
if(img != null){
var imgWidth = img.width;
var imgHeight = img.height;
if(imgWidth>width&&imgHeight>height){
//both image's width and height are larger than required one
var widthRate = imgWidth/width;
var heightRate = imgHeight/height;
if(widthRate>heightRate){
//use width to retrieve the image
img.width=width;
img.height=imgHeight*(width/imgWidth);
}else{
img.height=height;
img.width=imgWidth*(height/imgHeight);
}
}
else if(imgWidth>width){
//the image width lg than the required width
img.width=width;
img.height=imgHeight*(width/imgWidth);
}
else if(imgHeight>height){
//the image height lg than the required
img.height=height;
img.width=imgWidth*(height/imgHeight);
}
}
}
</script>
ouyang3857116 2009-07-03
  • 打赏
  • 举报
回复
把这个函数scalePhoto贴出来看看
dyiajure 2009-07-03
  • 打赏
  • 举报
回复
别沉啊,谁来解答下
dyiajure 2009-07-02
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 ralpha08 的回复:]
你的OnLoad应该是想设置为客户端事件

需要在你的datagrid的ItemDatabound事件中设置Image1的客户端事件


[/Quote]
主要想让datagrid显示的图片适应页面格式的大小,不需要客户端事件啊?
ralpha08 2009-07-02
  • 打赏
  • 举报
回复
你的OnLoad应该是想设置为客户端事件

需要在你的datagrid的ItemDatabound事件中设置Image1的客户端事件

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧