AegHero
WebPart에 대한 마크 업이있는 곳에 ASCX 파일 이 있습니다. 또한 BackgroundColor
클래스 이름을 보유 하는 속성이 있는데, 해당 클래스 이름은 특정 배경색을 가진 클래스에 해당합니다.
내 문제는 코드의 값을 올바르게 정의하지 않는다는 것입니다. 사용자가 색상을 선택하도록 드롭 다운 메뉴를 사용하고 있습니다.
다음은 내 AegHero.ascx입니다.
<asp:PlaceHolder runat="server">
<div id="mainHeroContainer" class="fullWidth-hero-container <%= BackgroundColor %>">
<div class="fullWidth-hero-container-inner">
<h2 class="fillWidth-hero-title"><%=Title %></h2>
<p class="fillWidth-hero-subtilte"><%=SubTitle %></p>
<% if (ShowButton)
{%>
<a class="btn button" href="<%= ButtonUrl %>"><%= ButtonLabel %></a>
<%} %>
</div>
</div>
</asp:PlaceHolder>
내 코드는 다음과 같습니다.
public partial class AegHero : GenericWebPart
{
protected string Title => Html("Title", string.Empty);
protected string SubTitle => Html("subTitle", string.Empty);
protected bool ShowButton => GetBooleanValue("ShowButton", false);
protected string ButtonUrl => StringProperty("ButtonUrl", string.Empty);
protected string ButtonLabel => StringProperty("ButtonLabel", string.Empty);
protected string BackgroundColor
{
get { return StringProperty("BackgroundColor", string.Empty); }
set { BackgroundColor = value; }
}
public override void OnContentLoaded()
{
base.OnContentLoaded();
if (BackgroundColor.CompareTo("#002147") == 0)
{
BackgroundColor = "perussian-backGround";
}
else if (BackgroundColor.CompareTo("#0077c2") == 0)
{
BackgroundColor = "lochmara-backGround";
}
else if (BackgroundColor.CompareTo("#858e99") == 0)
{
BackgroundColor = "gray-backGround";
}
}
}
}
내 CSS 클래스는 다음과 같습니다.
.gray-backGround {
background: #858e99;
}
.lochmara-backGround {
background: #0077c2;
}
.perussian-backGround {
background: #002147;
}
<%= BackgroundColor %>
받은 16 진수 값에 따라 설정하려고합니다 . 그러나 크롬 관리자를 보면 클래스가 변경되지 않습니다. backgroundColor 속성에서 값을 올바르게 가져 와서 어떻게 설정할 수 <div>
있습니까?
Chrome 검사기 :
시작하기 위해 사용자 지정 웹 파트 를 생성 / 개발 하는 방법을 살펴볼 수 있습니다 . 나는 당신이 공용 속성이기 때문에 UI의 웹 파트에서 저장된 값을 검색하지 않기 때문에 이것을 말합니다. 다음은 표준 속성 예입니다.
public string BackgroundColor
{
get
{
return DataHelper.GetNotEmpty(GetValue("BackgroundColor"), string.Empty);
}
set
{
SetValue("BackgroundColor", value);
}
}
이 GetValue("BackgroundColor")
메서드는 Kentico UI의 웹 파트 속성에서 생성 한 열의 문자열 이름을 취하고 주어진 페이지 / 템플릿에 대해 데이터베이스에 저장된 값을 검색합니다. 이렇게하면 편집기가 Kentico 프런트 엔드 UI에서 색상을 선택하거나 입력 할 수 있으며 코드에서 사용할 수 있습니다.
문서에 대한 자세한 내용을 읽으면 올바른 방향으로 나아갈 수 있습니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다