-1
/텍스트 상자 : 여기HTML 도우미 내가보기에이 입력을 검증
<%= Html.TextBoxCurrentDateWithoutPermission("EffectiveDate", Model.EffectiveDate.HasValue ? Model.EffectiveDate.Value.ToString("dd-MMM-yyyy") : "", new string[] { PERMISSIONS.hasICAdvanced }, new { @class = "economicTextBox", propertyName = "EffectiveDate", onchange = "parseAndSetDt(this); ", dataType = "Date" })%>
사용자 정의 HTML 도우미입니다 :
public static MvcHtmlString TextBoxCurrentDateWithoutPermission(
this HtmlHelper htmlHelper,
string name,
object value,
string[] permissions,
object htmlAttributes
)
{
foreach (string permission in permissions)
{
if (Chatham.Web.UI.Extranet.SessionManager.DisplayUser.IsInRole(permission))
{
// the user has the permission => render the textbox
return htmlHelper.TextBox(name, value, htmlAttributes);
}
}
// the user has no permission => render a readonly checkbox
var mergedHtmlAttributes = new RouteValueDictionary(htmlAttributes);
mergedHtmlAttributes["disabled"] = "disabled";
return htmlHelper.TextBox(name, value == "" ? DateTime.Now : value, mergedHtmlAttributes);
}
이 지금 작동하는 방식으로, 사용자가되지 않습니다 권한이 전달되면 상자가 비활성화됩니다.
필요한 방식 - 사용자가 전달 된 권한이없는 경우 사용하도록 설정해야하지만 허용 할 수있는 날짜는 앞으로의 날짜와 날짜뿐입니다. 텍스트 상자가 활성화 된 경우
및 사용자는 권한이 입력을 사용자에게 허용하지 않습니다
그래서 나는 다음과 같은 경우에 대한 페이지에서이 텍스트 상자를 들어, JQuery와 유효성 검사 (또는 그냥 일반 JS)가 필요합니다 현재 날짜 또는 미래 날짜 만.