画像をトリミングして保存しています。btnsave_click で、hiddenfield の値を 10 進数に変換しています。ローカル マシンではエラーは発生しませんが、サーバーに公開すると以下のエラーが発生します。
サーバーの詳細な例外:
入力文字列は、正しい形式ではありませんでした。
説明: 現在の Web 要求の実行中に未処理の例外が発生しました。エラーの詳細とコード内のどこでエラーが発生したかについては、スタック トレースを確認してください。
例外の詳細: System.FormatException: 入力文字列が正しい形式ではありませんでした。
ソース エラー:
現在の Web 要求の実行中に未処理の例外が生成されました。例外の発生元と場所に関する情報は、以下の例外スタック トレースを使用して特定できます。
スタックトレース:
[FormatException: 入力文字列が正しい形式ではありませんでした。]
System.Number.StringToNumber(文字列 str, NumberStyles オプション, NumberBuffer& 数値, NumberFormatInfo 情報, Boolean parseDecimal) +10726387 System.Number.ParseDecimal(文字列値, NumberStyles オプション, NumberFormatInfo numfmt ) +172
System.Convert.ToDecimal(文字列値) +68
IngredientMatcher.Pages.ImageCropPopup.btnsave_Click(オブジェクト送信者、EventArgs e) +104
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9552602
System.Web .UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +103
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) + 1724年
コード::
protected void btnsave_Click(object sender, EventArgs e)
{
string ImageName = ViewState["ImageName"].ToString();
int www = Convert.ToInt32(Math.Round(Convert.ToDecimal(W.Value)));
int hhh = Convert.ToInt32(Math.Round(Convert.ToDecimal(H.Value)));
int xxx = Convert.ToInt32(Math.Round(Convert.ToDecimal(X.Value)));
int yyy = Convert.ToInt32(Math.Round(Convert.ToDecimal(Y.Value)));
int w = (www == 0) ? 0 : www;
int h = (hhh == 0) ? 0 : hhh;
int x = (xxx == 0) ? 0 : xxx;
int y = (yyy == 0) ? 0 : yyy;
byte[] CropImage = Crop(Server.MapPath(" ") + "\\" + upPath + 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 = Server.MapPath("") + "\\" + CropPath + "crop" + ImageName;
CroppedImage.Save(SaveTo, CroppedImage.RawFormat);
imgCropped.BorderWidth = 1;
imgCropped.ImageUrl = CropPath + "crop" + ImageName;
}
}
string CroppedImg = "crop" + ViewState["ImageName"].ToString();
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "OpenPopUp", "javascript:SaveAndClose('" + CroppedImg + "');", true);
}
前もって感謝します。