.NET - 你如何注册一个启动脚本? [英] .net - How do you Register a startup script?

查看:151
本文介绍了.NET - 你如何注册一个启动脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有限的。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?

推荐答案

您会使用<一个href="http://msdn.microsoft.com/en-us/library/z9h4dk8y.aspx">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)
}

这篇关于.NET - 你如何注册一个启动脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆