2013-09-07 2 views
0

의 사용자 코드에 의해 처리되지 않았습니다. 오류 메시지가 계속 나타납니다. 또한, 코드를 실행할 때 전혀 작동하지 않는 것 같습니다. 다른 페이지로 데이터를 전달하려고합니다. 어떠한 제안? 이 형식 코드가 C#

public partial class _Default : System.Web.UI.Page 
{ 
static int numBeachBookingInt = 0; 
static int numBushBookingInt = 0; 
static decimal totRevenue = 0; 

protected void Page_Load(object sender, EventArgs e) 
{ 
    string totalRevenue; 
    if (Convert.ToString(Session["confirmBooking"]) == "confirm" && Convert.ToString(Session["bachType"]) == "bush") 
    { 
     totalRevenue = (string)(Session["totalRevenue"]); 
     totRevenue += decimal.Parse(totalRevenue); 
     totRevenueLabel.Text = String.Format("{0:c}", totRevenue); 
     numBushBooking += 1; 
     numBushHouseLabel.Text = numBushBooking.ToString(); 
     Session["confirmBooking"] = "no current booking"; 
     Session["bachType"] = "none"; 
    } 
    else if (Convert.ToString(Session["confirmBooking"]) == "confirm" && Convert.ToString(Session["bachType"]) == "beach") 
    { 
     totalRevenue = (string)(Session["totalRevenue"]); 
     totRevenue += decimal.Parse(totalRevenue); 
     totRevenueLabel.Text = String.Format("{0:c}", totRevenue); 
     numBeachBooking += 1; 
     numBeachHouseLabel.Text = numBeachBooking.ToString(); 
     Session["confirmBooking"] = "no current booking"; 
     Session["bachType"] = "none"; 
    } 
    numBeachHouseLabel.Text = numBeachBooking.ToString(); 
    numBushHouseLabel.Text = numBushBooking.ToString(); 

번째이며, 메인 페이지의 코드이다.

protected void confirmButton_Click(object sender, EventArgs e) 
{ 
    Session["confirmBooking"] = "confirm"; 
    Session["totalRevenue"] = totalRateLabel.Text; 
    switch (bachTypeRadioButtonList.Text) 
    { 
     case "Beach": 
      Session["bachType"] = "beach"; 
      break; 
     case "Bush": 
      Session["bachType"] = "bush"; 
      break; 
     default: 
      Session["bachType"] = "none"; 
      break; 
    } 
    Response.Redirect("MainBookingForm.aspx"); 
} 
+0

디버거에서 실행할 때 예외를 볼 수없는 경우 일부 catch try 문을 넣으십시오. @musical_coder 제안은 시작하기 좋은 곳입니다. – miltonb

답변

0

스택 추적이없는 정확한 문제를 아는 것은 어렵습니다. 그러나 검색을 기반으로 "형식 예외가 사용자 코드에 의해 처리되지 않았습니다"라는 문구를 사용하면 decimal.Parse(totalRevenue); 문 중 하나가 문제가 될 수 있습니다. totalRevenue의 문자열 값이 totalRateLabel.Text에서 설정 되었기 때문에 처음에 제거해야하는 특수 문자 (예 : 달러 기호)가 레이블에 포함되어 있으면 놀랄 일이 아닙니다.

+0

당신이 말했듯이, 두 번째 줄 totRevenue + = decimal.Parse (totalRevenue); 첫 줄이 아님 totRevenue + = decimal.Parse (totalRevenue); 문제가 발생하지만 라벨 컨트롤에 특수 문자를 추가하지 않았습니다. – user2699500

+0

문제의 근본 원인은 totalRevenue를 10 진수로 구문 분석 할 수 없다는 것입니다. Decimal.Parse()를 호출하기 직전에 totalRevenue를 텍스트 파일에 로깅하는 것이 좋습니다. 그렇게하면 totalRevenue의 나쁜 가치가 무엇인지 빠르게 알 수 있습니다. 그 일이 어떻게 진행되는지 알려주세요. –

+0

고정 소수점 totRevenue를 설정했기 때문에 그렇습니까? ... 조금 잃어 버렸습니다. – user2699500