两个TextBox1控件,一个是宽度一个是高度。还有一个图形(也就是图片)。和一个确定按钮,当输入高度和宽度之后点击确定图片会自动随即的做出变化。这个代码如何写呀求助

解决方案 »

  1.   

    最简单的 控制 IMage 的宽度和高度 .
     或者你按这个比例 重新生成缩略图 .
     搜 "asp.net生成缩略图 "
      

  2.   

    1,如果页面可以刷新,那就提交 textbox的数据,后台接收后,
    再输入 <img src=xxx style="width:20px;height:50px">2.一般人都不会接收1这种提交刷新的效果.
    最常用的是用javascript动态改变图片宽高<input type=button onclick="change()" value="改变">function change()
    {
    document.getElementById("图片id").style.width=....
    document.getElementById("图片id").style.height=....
    }
      

  3.   

    缩略图
    <script language="JavaScript"> 
    var flag=false; 
    function DrawImage(ImgD){ 
    var image=new Image(); 
    image.src=ImgD.src; 
    var h=parseInt(document.getElementById("textbox1").value);
    var w=parseInt(document.getElementById("textbox2").value);
    if(image.width>0 && image.height>0){ 
    flag=true; 
    if(image.width/image.height>= w/h){ 
    if(image.width>w){ 
    ImgD.width=w; 
    ImgD.height=(image.height*w)/image.width; 
    }else{ 
    ImgD.width=image.width; 
    ImgD.height=image.height; 


    else{ 
    if(image.height>h){ 
    ImgD.height=h; 
    ImgD.width=(image.width*h)/image.height; 
    }else{ 
    ImgD.width=image.width; 
    ImgD.height=image.height; 




    </script>