0
在課堂ModelError的構造均在控制器如何在if語句中顯示信息?
public ActionResult ModeError()
{
return View("ModeError", new Models.ModeErrorInfo(this.Url.RequestContext.RouteData.Values));
}
良好 鑑於
<% if (this.Model.SPECIALTY == null || string.IsNullOrEmpty(this.Model.SPECIALTY))
{
Html.DisplayText(String.Format("{0} {1} is missing", Model.ParametrType, Model.Speciality));
} %>
<% else
{
Html.DisplayText(String.Format("{0} {1} {2}", Model.ParametrType, Model.Speciality, Model.SPECIALTY));
} %>
public class ModeErrorInfo
{
#region Constants
public readonly string Session = "SESS";
public readonly string Mode = "MODE";
public readonly string App = "APP";
public readonly string Usertype = "USERTYPE";
public readonly string Speciality = "SPECIALTY";
public readonly string ParametrType = "URL";
#endregion
#region Public Properties
public string SESS { get; set; }
public string APP { get; set; }
public string USERTYPE { get; set; }
public string SPECIALTY { get; set; }
public string MODE { get; set; }
#endregion
#region Constructors
public ModeErrorInfo(RouteValueDictionary values)
{
if (values != null)
{
this.APP = (string)values[this.App];
this.SESS = (string)values[this.Session];
this.SPECIALTY = (string)values[this.Speciality];
this.USERTYPE = (string)values[this.Usertype];
this.MODE = (string)values[this.Mode];
}
}
#endregion
}
但我給空視圖下執行後!我如何顯示這些信息?
你在問什麼?你看到什麼問題? – 2011-03-17 17:37:00
執行後不是信息。 – isxaker 2011-03-17 17:37:57