온라인 사용자 텍스트가 아닌 온라인 사용자에게 다른 텍스트를 표시하려면 사용자 정의보기 모드가 필요합니다.using 문이 실행되지 않도록하기
하지만 using 문에서 Html.BeginForm()
처럼하고 싶습니다.
클래스 마녀는 텍스트와 텍스트의 시작 부분에 텍스트를 쓸 수있게 만들었지 만 {}에있는 텍스트가 멈추지 않도록 할 수 있습니다.
@using (AuthorizedContent(Html, "Adminstrator"))
{
<text>Only the administrator should see this</text>
}
는
public static Test AuthorizedContent(this HtmlHelper helper, String roleName)
{
return null;
var test = new Test(helper);
return test;
}
public class Test : IDisposable
{
private HtmlHelper _helper;
public Test(HtmlHelper helper) {
_helper = helper;
this.StartTag();
}
public void StartTag()
{
var writer = _helper.ViewContext.Writer;
writer.Write("Hello");
}
public void EndTag()
{
var writer = _helper.ViewContext.Writer;
writer.Write("Hello");
}
void IDisposable.Dispose()
{
this.EndTag();
}
}
을 그냥 4 줄을 지우면 그들은 일어나지 않을 것입니다. 진정한 목표는 무엇입니까? – sehe
왜 using 문 본문이 렌더링되지 않도록 하시겠습니까? 요점이 뭐야? –
@KirkWoll : 나는 OP가 사용자가 관리자가 아닐 때 using 문을 렌더링하지 못하도록하고 싶습니다. – dtb