0
IScriptControl을 구현하는 복합 컨트롤을 만들고 있습니다. 을 CreateChildControls에서javascript 함수에 액세스하는 복합 컨트롤
() 함수 난이있다 :
HtmlGenericControl ul = new HtmlGenericControl("ul");
HtmlGenericControl b2 = new HtmlGenericControl("li");
b2.Style["background-image"] = string.Format("url({0})", imageSrc);
b2.Style["list-style"] = "none";
b2.Style["background-repeat"] = "no-repeat";
b2.Style["background-position"] = "center center";
b2.Style["border-style"] = "none";
b2.Style["width"] = "20px";
b2.Style["height"] = "20px";
b2.Style["float"] = "left";
b2.InnerHtml = " ";
b2.Attributes["onmouseover"] =
b2.Attributes["onmouseout"] =
ul.Controls.Add(b2);
barContainer.Controls.Add(ul);
제가 필요하면
b2.Attributes 설정하는 것 [ "onMouseover와"를]
및
b2.Attributes [ "onmous eout "]
Prototype Model에 정의 된 Javascript 기능의 속성.
ProjectW.Edition.prototype = {
.
.
.
MouseOver: function(ctrl)
{
DoWork...
},
MouseOut: function(ctrl)
{
DoWork...
},
이 필요 경우
#region IScriptControl Implementation
protected virtual IEnumerable<ScriptReference> GetScriptReferences()
{
ScriptReference reference = new ScriptReference();
reference.Assembly = "ProjectW";
reference.Name = "ProjectW.EditonScripts.js";
return new ScriptReference[] { reference };
}
protected virtual IEnumerable<ScriptDescriptor> GetScriptDescriptors()
{
ScriptControlDescriptor descriptor = new ScriptControlDescriptor("ProjectW.Edition", this.ClientID);
descriptor.AddProperty(....);
);
return new ScriptDescriptor[] { descriptor };
}
IEnumerable<ScriptReference> IScriptControl.GetScriptReferences()
{
return GetScriptReferences();
}
IEnumerable<ScriptDescriptor> IScriptControl.GetScriptDescriptors()
{
return GetScriptDescriptors();
}
#endregion
UPDATE : 동적을 CreateChildControls 내부에서 발생하는 HTML 요소 - 런타임에.
디자인 타임 지원이 필요하기 때문에 CompositeControl을 사용합니다. – markiz
컨트롤에 많은 요소가 있습니다. 내 사례 시나리오를 보여주기 위해 하나의 섹션 만 붙여 넣었습니다. – markiz
$ addHandlers in initialize 함수는 정적 일 수 없습니다. 왜냐하면 마크 업에서 생성 된 li 요소가 동적으로 생성되기 때문입니다. – markiz