如果页面没有错误,我试图在点击保存按钮时显示验证消息,有人可以告诉我为什么我无法访问CssClass
validationMessage
属性在这种情况下?
<div id="validationMessage" ClientIDMode="Static" runat="server" class="hidden">
Please fix any errors on the page before saving.
</div>
protected void cmdSave_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
//stuff
}
else
{
validationMessage.CssClass = validationMessage.CssClass.Replace("hidden", "");
}
}