我正在尝试使用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); 发布于 2012-04-20 00:28:42
这段代码就是我用到的
在客户端,我有这样的..但我不认为这是个问题
var updateCoords = function(c) {
$('#x').val(c.x);
$('#y').val(c.y);
$('#w').val(c.w);
$('#h').val(c.h);
};在服务器"upload.ashx“通用处理程序上,我使用以下命令获取维度
Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
Dim x As Integer = Integer.Parse(context.Request("x"))
Dim y As Integer = Integer.Parse(context.Request("y"))
Dim w As Integer = Integer.Parse(context.Request("w"))
Dim h As Integer = Integer.Parse(context.Request("h"))除此之外,你是从哪里得到错误的?在客户端还是在服务器上?什么是抛出它?
而且看起来您试图在回发后获取表单值,这些表单值不再存在,因为此时页面已经重新初始化,没有原始值。因为这就是.NET页面呈现过程的工作方式。
因此,您必须将变量保存到内存中的会话,将值回发到自身并使用Request.Form检索它们,或者使用GET方法发送数据并检索值,就像我所做的那样
发布于 2012-07-05 03:29:06
我也遇到了同样的问题,并通过以下方式解决了它:
var updateCoords = function(c) {
$('#x1').val(Math.round(c.x));
$('#y1').val(Math.round(c.y));
$('#x2').val(Math.round(c.x2));
$('#y2').val(Math.round(c.y2));
$('#w').val(Math.round(c.w));
$('#h').val(Math.round(c.h));
};发布于 2014-02-03 19:25:01
jQuery('#X').val(Math.round(c.x));
jQuery('#Y').val(Math.round(c.y));
jQuery('#W').val(Math.round(c.w));
jQuery('#H').val(Math.round(c.h));https://stackoverflow.com/questions/10231456
复制相似问题