0
我有一個網格視圖與兩列有下拉列表。只要選擇了一個值,該下拉列表就會保存。我想阻止用戶在第二個下拉列表中選擇一個值,而不從第一個值中選擇一個值。所以第一個下拉列表不應該是空白的。有沒有辦法阻止異常消息中的所有額外文本?
public static void UpdateMemReasonSecond(int SerNoID, string sel)
{
JobOutturn SerNo = new JobOutturn(SerNoID);
SerNo.MemReasonSecond = sel;
SerNo.MemDate = DateTime.Now;
SerNo.MemUser = CurrentUser.Username;
SerNo.Update();
if (SerNo.MemReason == "" & SerNo.MemReasonSecond != "")
{
throw new Exception("Please fill in first reason");
}
}
jQuery代碼:
function UpdateMemReasonSecond(SerNoID, sel) {
PageMethods.UpdateSecondMemReasonUserControl(SerNoID, sel, OnUpdateSuccess, OnUpdateFailReason);
}
所以異常的作品,但在出現的錯誤信息中包含了很多額外的線,不只是我的消息。有沒有辦法只顯示我的消息?
'ex.Message',你的意思是? – CodeCaster
您不應該爲此使用異常 –
「不要從您的源代碼故意拋出System.Exception,System.SystemException,System.NullReferenceException或System.IndexOutOfRangeException。」 https://msdn.microsoft.com/en-us/library/ms173163.aspx –