Ajax中的UpdatePanel与Freetextbox兼容问题的初步解决方法

摘自: 杜隆塔尔的红色海岸
Ajax中的UpdatePanel与Freetextbox兼容问题的初步解决方法

 默认情况下不兼容是因为UpdatePanel提交后FreeTextBox没有再次初始化造成的。
解决方法是在引用了FreeTextBox控件的页面代码中增加以下代码,即可实现手工初始化:

protected void Page_Load(object sender, EventArgs e)
{
        if (!Page.IsPostBack)
        {
            Page.ClientScript.RegisterClientScriptInclude("FTB-FreeTextBox", VirtualPathUtility.MakeRelative(Request.Path, "~/scripts/FTB-FreeTextBox.js"));
            Page.ClientScript.RegisterClientScriptInclude("FTB-Utility", VirtualPathUtility.MakeRelative(Request.Path, "~/scripts/FTB-Utility.js"));
            Page.ClientScript.RegisterClientScriptInclude("FTB-Toolbars", VirtualPathUtility.MakeRelative(Request.Path, "~/scripts/FTB-ToolbarItems.js"));
            Page.ClientScript.RegisterClientScriptInclude("FTB-ImageGallery", VirtualPathUtility.MakeRelative(Request.Path, "~/scripts/FTB-ImageGallery.js"));
            Page.ClientScript.RegisterClientScriptInclude("FTB-Pro", VirtualPathUtility.MakeRelative(Request.Path, "~/scripts/FTB-Pro.js"));
        }
}

public new void RegisterOnSubmitStatement(string key, string script)
{
    ScriptManager.RegisterOnSubmitStatement(this, typeof(Page), key, script);
}

[Obsolete]
public override void RegisterStartupScript(string key, string script)
{
    string newScript = script.Replace("FTB_AddEvent(window,'load',function () {", "").Replace("});", "");
    ScriptManager.RegisterStartupScript(this, typeof(Page), key, newScript, false);
}

你可能感兴趣的:(UI,Tech)