【问题标题】:Asp.net, Jcrop value issueAsp.net, Jcrop 价值问题
【发布时间】:2012-05-04 09:56:48
【问题描述】:

我试图让 Jcrop 与 Asp.net 一起工作,但我认为我遇到了以下问题:

Convert.ToInt32(W.Value);

我在我的 aspx 页面中使用隐藏字段。我尝试使用常规输入字段,然后编写了一个请求表单来获取所有值,这很有效。但我无法让它与隐藏字段和 Convert.ToInt32(W.Value) 一起使用。当我尝试这种方式时,该值似乎总是为空。我收到消息:输入的格式不正确。

我的后台代码如下所示:

protected void btnCrop_Click(object sender, EventArgs e)
{
    string ImageName = Request.QueryString["upload"];
    String path = "~/Members/TemporaryProfilePhotos/";

    int w = Convert.ToInt32(W.Value);
    int h = Convert.ToInt32(H.Value);
    int x = Convert.ToInt32(X.Value);
    int y = Convert.ToInt32(Y.Value);

    byte[] CropImage = Crop(path + ImageName, w, h, x, y);

    using (MemoryStream ms = new MemoryStream(CropImage, 0, CropImage.Length))
    {
        ms.Write(CropImage, 0, CropImage.Length);
        using (SD.Image CroppedImage = SD.Image.FromStream(ms, true))
        {
            string SaveTo = path + "crop" + ImageName;
            CroppedImage.Save(SaveTo, CroppedImage.RawFormat);
        }
    }
}

static byte[] Crop(string Img, int Width, int Height, int X, int Y)
{
  try {
    using (SD.Image OriginalImage = SD.Image.FromFile(Img)) {
      using (SD.Bitmap bmp = new SD.Bitmap(Width, Height)) {
        bmp.SetResolution(OriginalImage.HorizontalResolution,
          OriginalImage.VerticalResolution);

        using (SD.Graphics Graphic = SD.Graphics.FromImage(bmp)) {
          Graphic.SmoothingMode = SmoothingMode.AntiAlias;
          Graphic.InterpolationMode = InterpolationMode.HighQualityBicubic;
          Graphic.PixelOffsetMode = PixelOffsetMode.HighQuality;
          Graphic.DrawImage(OriginalImage,
            new SD.Rectangle(0, 0, Width, Height),
            X, Y, Width, Height, SD.GraphicsUnit.Pixel);
          MemoryStream ms = new MemoryStream();
          bmp.Save(ms, OriginalImage.RawFormat);
          return ms.GetBuffer();
        }
      }
    }
  }

  catch (Exception Ex) {
    throw (Ex);
  }
} 

【问题讨论】:

    标签: c# asp.net jcrop


    【解决方案1】:

    如果您通常在.net 中将Visible property 设置为false;,则control 将不会在页面为processed 后的HTML 输出中呈现

    所以您可以尝试使用 style="visibility: hidden; display: none;" 的隐藏字段

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-12
      • 2014-11-12
      • 2014-10-10
      • 2012-12-16
      • 1970-01-01
      相关资源
      最近更新 更多