Scriptcontrolのクライアント側とサーバー側でプロパティをバインドすることは可能ですか?javascriptでプロパティを設定すると、コードの背後でも変更が表示されます。変更はjavascriptで表示されますか?ScriptControl - クライアントとサーバーのプロパティをバインドする
私はそれが上記のように動作し得ることができません - それは私がのScriptControlが宣言されたプロパティを設定すると、最初に設定されますが、私は後でそれを変更するとき、それはまだ前に...
EDITと同じです。私は、ASP.NETアプリケーションで長いポストバックのためにProgressBarを実行しようとしています。私は多くのオプションを試しましたが、どれも私のために働いていません...コードの進捗度を設定して、長いタスクのポストバック中にビューで更新しました。
のScriptControlのためのコード: のC#:
public class ProgressBar : ScriptControl
{
private const string ProgressBarType = "ProgressBarNamespace.ProgressBar";
public int Value { get; set; }
public int Maximum { get; set; }
protected override IEnumerable<ScriptDescriptor> GetScriptDescriptors()
{
this.Value = 100;
this.Maximum = 90;
var descriptor = new ScriptControlDescriptor(ProgressBarType, this.ClientID);
descriptor.AddProperty("value", this.Value);
descriptor.AddProperty("maximum", this.Maximum);
yield return descriptor;
}
protected override IEnumerable<ScriptReference> GetScriptReferences()
{
yield return new ScriptReference("ProgressBar.cs.js");
}
}
Javascriptを:
Type.registerNamespace("ProgressBarNamespace");
ProgressBarNamespace.ProgressBar = function(element) {
ProgressBarNamespace.ProgressBar.initializeBase(this, [element]);
this._value = 0;
this._maximum = 100;
};
ProgressBarNamespace.ProgressBar.prototype = {
initialize: function() {
ProgressBarNamespace.ProgressBar.callBaseMethod(this, "initialize");
this._element.Value = this._value;
this._element.Maximum = this._maximum;
this._element.show = function() {
alert(this.Value);
};
},
dispose: function() {
ProgressBarNamespace.ProgressBar.callBaseMethod(this, "dispose");
},
get_value: function() {
return this._value;
},
set_value: function (value) {
if (this._value !== value) {
this._value = value;
this.raisePropertyChanged("value");
}
},
get_maximum: function() {
return this._maximum;
},
set_maximum: function (value) {
if (this._maximum !== value) {
this._maximum = value;
this.raisePropertyChanged("maximum");
}
}
};
ProgressBarNamespace.ProgressBar.registerClass("ProgressBarNamespace.ProgressBar", Sys.UI.Control);
if (typeof (Sys) !== "undefined") Sys.Application.notifyScriptLoaded();
私は、このプログレスバーを実装する方法を感謝します...個人的に
私はあなたのアプローチがこれを行う最もエレガントな方法だと思います。私は興味があります、あなたはそれを動作させるために管理しましたか? – julealgon