Asp.net,Jcrop价值问题
本文关键字:问题 Jcrop net Asp | 更新日期: 2023-09-27 18:33:14
我试图让 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);
}
}
如果将
Visible property
设置为通常false;
.net
则在页面processed
后,control
将不会呈现在HTML
输出中
因此,您可以尝试使用隐藏字段style="visibility: hidden; display: none;"