.NET - 你如何注册一个启动脚本?脚本、NET

由网友(愛已陌生)分享简介:我有限的。NET的经验。我的应用程序引发错误this.dateTimeFormat是不确定的,我找到了一个已知的阿贾克斯错误。张贴解决方法说:I have limited experience with .net. My app throws an error this.dateTimeFormat is unde...

我有限的。NET的经验。我的应用程序引发错误this.dateTimeFormat是不确定的,我找到了一个已知的阿贾克斯错误。张贴解决方法说:

I have limited experience with .net. My app throws an error this.dateTimeFormat is undefined which I tracked down to a known ajax bug. The workaround posted said to:

注册以下为启动脚本:

Sys.CultureInfo.prototype._getAbbrMonthIndex = function(value)
{
if (!this._upperAbbrMonths) {
this._upperAbbrMonths = this._toUpperArray(this.dateTimeFormat.AbbreviatedMonthNames);
}
return Array.indexOf(this._upperAbbrMonths, this._toUpper(value));
};

那么,如何做到这一点?难道我添加脚本到我的aspx文件的底部?

So how do I do this? Do I add the script to the bottom of my aspx file?

推荐答案

您会使用ClientScriptManager.RegisterStartupScript()

string str = @"Sys.CultureInfo.prototype._getAbbrMonthIndex = function(value) { 
    if (!this._upperAbbrMonths) { 
    	this._upperAbbrMonths = this._toUpperArray(this.dateTimeFormat.AbbreviatedMonthNames);
    }
    return Array.indexOf(this._upperAbbrMonths, this._toUpper(value));
 };";

if(!ClientScriptManager.IsStartupScriptRegistered("MyScript"){
  ClientScriptManager.RegisterStartupScript(this.GetType(), "MyScript", str, true)
}
阅读全文

相关推荐

最新文章