在B2C自定义策略中,如何在InputClaim文本框上方添加提示信息?
实现方法
要在用户名输入框上方添加「请输入您的用户名」提示,可通过修改ClaimType的配置实现,以下是两种可行方案:
方案1:局部修改当前TechnicalProfile(推荐)
直接在目标TechnicalProfile中重定义signInName字段的属性,仅对密码重置页面生效,不影响其他流程:
<TechnicalProfile Id="SelfAsserted-LocalAccountLookup-Combined-PwdReset"> <!-- 新增ClaimsSchema节点,重定义signInName的提示信息 --> <ClaimsSchema> <ClaimType Id="signInName"> <DisplayName>用户名</DisplayName> <HelpText>请输入您的用户名</HelpText> <DataType>string</DataType> <UserInputType>TextBox</UserInputType> </ClaimType> </ClaimsSchema> <OutputClaims> <OutputClaim ClaimTypeReferenceId="signInName" Required="true" /> <OutputClaim ClaimTypeReferenceId="isEmailBoolean" /> <OutputClaim ClaimTypeReferenceId="objectId" /> </OutputClaims> <ValidationTechnicalProfiles> <ValidationTechnicalProfile ReferenceId="AAD-UserReadUsingIdentifier" /> <ValidationTechnicalProfile ReferenceId="regexAnalysisUsername" /> </ValidationTechnicalProfiles> <IncludeTechnicalProfile ReferenceId="SelfAsserted-LocalAccountLookup-Combined-SignUp" /> <UseTechnicalProfileForSessionManagement ReferenceId="SM-AAD" /> </TechnicalProfile>
方案2:全局修改ClaimType定义
如果希望所有使用signInName字段的页面都显示该提示,可在TrustFramework的ClaimsSchema中修改全局配置(通常在TrustFrameworkExtensions.xml文件中):
<ClaimsSchema> <ClaimType Id="signInName"> <DisplayName>用户名</DisplayName> <!-- 添加该行设置输入框上方提示 --> <HelpText>请输入您的用户名</HelpText> <DataType>string</DataType> <UserInputType>TextBox</UserInputType> </ClaimType> <!-- 其他ClaimType定义 --> </ClaimsSchema>
说明
HelpText属性的内容会根据UI主题布局,在输入框附近(通常为上方)作为提示信息展示- 若使用自定义UI模板,需确保模板支持渲染
HelpText内容,否则需调整模板代码匹配该属性
内容的提问来源于stack exchange,提问作者KevinG
相关产品推荐
相关产品推荐

