做了一个图片显示的网页,网页上有用html image控件显示图片,src = "xxxx.aspx",图片从数据库中读出后用Response.BinaryWrite( (byte[])dt1["Picture"])。但图片显示后,图片占满了页面,其它控件都没有了。请问各位高手如何解决这个问题.多谢!

解决方案 »

  1.   

    指定固定大小试试 Height="90px" Width="496px"
      

  2.   

    <img border="0" src="a.gif" width="50" height="50">
      

  3.   

    html image控件可以设置他的宽、高
    宽、高也可以设置成百分比,比如50%
      

  4.   

    问题就出在那句Response.BinaryWrite( (byte[])dt1["Picture"])了!呵呵.把显示图像的部分做成一个单独的页面,然后调用该页面,如<img src="xxxx.aspx?img=image.jpg">
      

  5.   

    width="100" height="100"显示图像的部分做成一个单独的页面,然后调用该页面
      

  6.   

    在图片的那部分写上width 和 height<img src='' width="" height="">
      

  7.   

    用width和height来控制也看不见其他控件???
      

  8.   

    <script language="VB" runat="server">
    Sub UploadFile(sender As Object, e As EventArgs)If FileUp.PostedFile.ContentLength = 0 Then
    FileInfo.Visible = False
    Exit Sub
    Else
    FileInfo.Visible = True
    FDisplay1.Visible = True
    End IfFSize.Text ="上传文件大小"+ CStr(FileUp.PostedFile.ContentLength/1024)+"KB"
    FName.Text = "已上传文件名:"+FileUp.PostedFile.FileName+"<br>"+FName.Text'写入数据库
    on error resume next
    dim myconn as sqlconnection
    dim mycomm as sqlcommand
    dim sql as string
    dim id as integer
    Dim image,anewimage As System.Drawing.Image
    dim width,height,newwidth,newheight as integer
    Dim callb As System.Drawing.Image.GetThumbnailImageAbort
    myConn=New sqlconnection(ConfigurationSettings.AppSettings("数据库"))
    myconn.open()
    sql="insert into picture (姓名,班级,介绍,属性) values ('"&request.cookies("dgxyl").values("dgxylname")&"','"&request.cookies("dgxyl").values("dgxylbj")&"','"&trim(request("TextBox1"))&"','"&request("r1")&"')"
    Mycomm=New sqlcommand(sql,myconn)
    mycomm.executenonquery()
    myconn.close()Dim myCommand As New SqlCommand("select top 1 id from picture order by id desc", myConn)
    myCommand.Connection.Open()
    Dim myReader As SqlDataReader=mycommand.executereader()
    if myReader.Read() then
    id=myReader("id")
    end if
    myconn.close()
    '保存图片
    FileUp.PostedFile.SaveAs( Server.MapPath("\classpic\")&cstr(id)&".jpg" )
    '生成缩略图
    image=System.Drawing.Image.FromFile(Server.MapPath("/classpic/"+cstr(id)+".jpg"))
    width=image.Width
    height=image.height
    if width>height then
    newwidth=250
    newheight=image.height/image.Width*newwidth
    else
    newheight=250
    newwidth=image.Width/image.height*newheight
    end if
    response.write("id="+cstr(id)+"width="+cstr(Width)+";height="+cstr(height)+"  ")
    response.write("newwidth="+cstr(newwidth)+";newheight="+cstr(newheight)+"<br>")aNewImage=image.GetThumbnailImage(newwidth,newheight,callb,new System.IntPtr())
    aNewImage.Save(Server.MapPath("/smallpic/"+cstr(id)+".jpg"))
    image.Dispose()
    Dim FileSplit() As String = Split( FileUp.PostedFile.FileName, "\" )
    Dim FileName As String = FileSplit(FileSplit.Length-1)
    Dim Exts() As String = Split( FileName, "." )
    Dim Ext As String = LCase(Exts(Exts.Length-1))FDisplay.Text = "<A Target='_blank' HREF='/classpic/"&cstr(id)&".jpg"& "'>查看上传文件</A>"
    FDisplay1.text="<a href='/picture/default.asp?bj="&cstr(request.cookies("dgxyl").values("dgxylbj"))&"'>返回</a>"
    End Sub
    </script>
    <SCRIPT language=JavaScript>
    <!--
    var requestsubmitted=false;
    function guestbook_Validator(theForm)
    {
    //检查是否从新提交
    if (requestsubmitted==true){
      alert("你已经提交了留言,请等待服务器应答!");
      return(false);
     }
    requestsubmitted=true;return (true);
    }
    //-->
    </SCRIPT>
    <Html>
    <Body BgColor=White>
    <H3 align="center">请正确填写下面各项</h3>
    <Hr></H3>
    <Div id="FileInfo" Visible="False" runat="server">
     <Asp:Label id="FSize" runat="server"/><br>
     <Asp:Label id="FName" runat="server"/><br>
    <Asp:Label id="FDisplay" runat="server"/>
     <Asp:Label id="FDisplay1" runat="server"/>
    </Div>
    <Form Enctype="multipart/form-data" onsubmit="return guestbook_Validator(this)" runat="server">
    上传文件
    <Input Type="File" id="FileUp" runat="server" size="20"><br>
    图片属性:<input type="radio" value="<%=request.cookies("dgxyl").values("dgxylbj")%>" name="R1" checked>本班<input type="radio" value="全校" name="R1">全校(本班则只在本班显示,全校则在全校显示)<P>
    图片说明:<br>
    <asp:TextBox id="TextBox1" runat="server" Width="233px" Height="141px">
    </asp:TextBox>
            <asp:RequiredFieldValidator id="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" ErrorMessage="请输入图片说明">
    </asp:RequiredFieldValidator><br>
    <Asp:button id="Upload" OnClick="UploadFile" Text="上传图片" runat="server"/>
    </form>
    <Hr>
    <p>注意:</p>
    <ol>
      <li><b>严禁上传污染环境的照片,否则账号将被删除!</b></li>
      <li><font color="#808000"><b>请详细填写照片说明,图片说明不详细将会被视为乱传图片,将会被删除!</b></font></li>
    </ol>
    <p> </p></Body>
    </Html>
      

  9.   

    在微软的讲座中提到,.net对图像的支持不是很好,如果在一个页面中利用流输出显示图像,那么其他的控件全部都会被屏蔽掉。而且利用流显示的图片,是无法控制大小的
      

  10.   

    微软目前提供的解决方案就是利用image控件链接到专门显示图片的页面,然后控制image控件的大小,呵呵
      

  11.   

    wagod(天使之恋) 说的不错,但我做成单独的页面总要添加一些诸如返回之类的东西吧!不知哪位高手能解决这个问题
      

  12.   

    <img src="a.gif" width="50" height="50">
      

  13.   

    诸如此类的问题 <img src="a.gif" width="50" height="50"> 大家级不要发了,多谢!
      

  14.   

    这篇文章再不能解决你的问题我自杀!
    http://www.ccw.com.cn/htm/center/prog/02_8_27_2.asp