.net - 如何注册启动脚本? [英] .net - How do you Register a startup script?
本文介绍了.net - 如何注册启动脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
注册以下作为启动脚本:
code> Sys.CultureInfo.prototype._getAbbrMonthIndex = function(value)
{
if(!this._upperAbbrMonths){
this._upperAbbrMonths = this._toUpperArray(this.dateTimeFormat。缩写的蒙特尼姆);
}
return Array.indexOf(this._upperAbbrMonths,this._toUpper(value));
};
那么我该怎么办?我将脚本添加到我的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)
}
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:
"Register the following as a startup script:"
Sys.CultureInfo.prototype._getAbbrMonthIndex = function(value)
{
if (!this._upperAbbrMonths) {
this._upperAbbrMonths = this._toUpperArray(this.dateTimeFormat.AbbreviatedMonthNames);
}
return Array.indexOf(this._upperAbbrMonths, this._toUpper(value));
};
So how do I do this? Do I add the script to the bottom of my aspx file?
解决方案
You would use 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屋!
查看全文