我想在不使用UpdatePanel的情况下将裁剪后的图像加载到asp:image中。但问题是它显示图像,但它需要加载$('。image-cropper')。each(linkUp);函数,它存在于jQuery(window).load()中以开始裁剪过程。但使用RegisterClientScriptBlock方法不会触发该函数。注意:$('。image-cropper')。each(linkUp);只有在用新图像更新图像后才能启动。任何人都可以让我知道错误在哪里?从C#中的按钮单击事件调用jQuery函数
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ImageResizer;
using System.Text;
public partial class Advanced : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) {
ScriptManager1.RegisterAsyncPostBackControl(Button1);
if(!IsPostBack)
Image1.ImageUrl = "fountain-small.jpg?width=300";
if (Page.IsPostBack && !string.IsNullOrEmpty(img1.Value))
ImageBuilder.Current.Build("~/"+ImageResizer.Util.PathUtils.RemoveQueryString(img1.Value), "~/cropped.jpg", new ResizeSettings(img1.Value));
}
protected void Button1_Click(object sender, EventArgs e)
{
Image1.ImageUrl = "cropped.jpg?width=300";
UpdatePanel1.Update();
string key = "executeCropScript";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), key, "<script
type=\"text/javascript\">jQuery(window).load();</script>", false);
}
}
你试过Page.ClientScript.RegisterStartupScript? MSDN:http://msdn.microsoft.com/en-us/library/asz8zsxy.aspx –
[从C#调用jQuery函数]的可能重复(https://stackoverflow.com/questions/7775491/calling-jquery-function -from-c-sharp)由同一用户 – Nitin