2013-05-14 55 views
-1

在我的應用程序中,我想重定向到錯誤頁面。有一個標籤會在錯誤頁面上顯示用戶友好的錯誤。我可以重定向到頁面。問題在於將標籤設置爲用戶友好的錯誤。然後重定向到錯誤頁面並顯示用戶友好錯誤

HttpContext.Current.Response.Redirect("ssperror.aspx?err_id=4"); 

在ssperror.aspx:

if (xy.Count() >= 1) 
{    
    foreach (var x in xy) 
    { 
     employeeEmploy.Add(x); 
     Debug.WriteLine(x.employee_personal_id); 
    } 
} 
else 
{ 
    Security.ErrorControl.displayErrorMsg = "Employee Employ currently doesn't have any persons inside"; 

    Debug.WriteLine(Security.ErrorControl.displayErrorMsg); // class that set and get the error message i want to display 

    HttpContext.Current.Response.Redirect("ssperror.aspx"); // I am getting to redirect .. just need to set the label to the error message. 

} 

回答

0

您可以(更甚至表示消息ID的ID)傳遞錯誤信息的查詢字符串,而重定向,所以最後一行將您可以分析參數err_id,檢索並顯示標籤中的錯誤消息:

if (Request.QueryString["err_id"] != null) 
{ 
    lbl_error.text = retrieve_errormessage_from_code(Request.QueryString["err_id"]); 
}