【发布时间】:2012-05-01 04:00:33
【问题描述】:
我正在尝试使用 Jcrop 裁剪图像。它不起作用,我不断收到异常“输入字符串格式不正确”。
<script type="text/javascript">
jQuery(document).ready(function () {
jQuery('#crop').Jcrop({
onSelect: updateCoords
});
});
function updateCoords(c) {
jQuery('#X').val(c.x);
jQuery('#Y').val(c.y);
jQuery('#W').val(c.w);
jQuery('#H').val(c.h);
};
<asp:Button ID="Submit" runat="server" Text="Crop"
onclick="Submit_Click" />
<asp:Image ID="Image" runat="server" Visible="False" />
<img src="Content/UploadedImage/Image.jpg" id="crop" alt=""/>
<asp:HiddenField ID="X" runat="server" />
<asp:HiddenField ID="Y" runat="server" />
<asp:HiddenField ID="W" runat="server" />
<asp:HiddenField ID="H" runat="server" />
试图获取坐标
protected void Submit_Click(object sender, EventArgs e)
{
if (IsPostBack)
{
int x = Convert.ToInt32(X.Value);
int y = Convert.ToInt32(Y.Value);
int w = Convert.ToInt32(W.Value);
int h = Convert.ToInt32(H.Value);
【问题讨论】:
-
您是否检查过您的 html 字段的 ID?或者至少在回发时在 X.Value、Y.Value... 中传递了哪些值?我猜你必须在 HiddenField 控件中包含
ClientIDMode="Static"。