2016-04-17 8 views
0

私はVisual Studio 2012でこのファイルを作成しました。調査の最初のページは完全にうまく動作しますが、「500内部サーバーエラー」を表示するように指示すると、プロジェクトにはコンパイルエラーはありません。私はfilezillaを使用してこのファイルを開いています誰でも私を助けてください。 survey.aspから値を取得し、値を次の形式で表形式で表示する単純なプログラムです。Ftp asp.netでfilezillaを使用

------ survey.asp -----------------------------

<!DOCTYPE html> 

<html lang="en" xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
    <meta charset="utf-8" /> 
    <title>Survey Form</title> 
</head> 
<body> 
    <form method="post" action="display.asp"> 
     <br/> 
     Please Enter Your Age <input type="text" name="first" value="<%=request("Age")%>"/> <br /> <br/> 
     Please Enter Your Salary $ <input type="text" name="sal" value="<%=request("salary")%>"/> <br /><br/> 
     What level of Education Have You Completed : <br/> 
     <input type="radio" name="radiobutton" value="<%=request("education")%>"/> Some High School <br /> 
     <input type="radio" name="radiobutton" value="<%=request("education")%>"/> Completed high School <br /> 
     <input type="radio" name="radiobutton" value="<%=request("education")%>"/>Some College Education <br /> 
     <input type="radio" name="radiobutton" value="<%=request("education")%>"/> Completed a B.S Degree <br /> 
     <input type="radio" name="radiobutton" value="<%=request("education")%>"/> Completed a Master Degree <br /> <br/> 
     <input type="submit" value="Send Survey" /> 
</form> 
</body> 
</html> 

- --------- display.asp ---------------------------------

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

    <% 
    Age = request.form("first") 
    salary = request.form("sal") 
    education = request.form("radiobutton").ToString(); 
    if age="" or salary="" or education="" then 
    %> 
<html> 
    <head><title></title></head> 
    <body> 
You must enter all the info 
<form method="post " action="survey.asp"> 
    <input type="hidden" name="age" value="<%=age%>" /> 
    <input type="hidden" name="salary" value="<%=salary%>" /> 
    <input type="hidden" name="education" value="<%=education%>" /> <br/> 
    <input type="submit" value="Return" /> 
</form> 

</body> 
</html> 

<% 
response.end 
end if 
%> 

<html xmlns="http://www.w3.org/1999/xhtml" > 
<head> 
    <title>Display Name</title> 
</head> 
<body> 

You entered: <br /> 
<table> 
<tr> 
    <td> <%=age%> </td> 
    <td> <%=salary%> </td> 
    <td> <%=education %> </td> 
</tr> 
</table> 

<br /> 
</body> 
</html> 

答えて

2

これはvbscriptでは古典的なASPであり、C#ではasp.netではありません。コンパイルされていないため、実行時に解釈されるため、古典的なコンパイルエラーは発生しません。

あなたはdisplay.aspでのC#のラインを入れているように見える - あなたはラインに

education = Cstr(request.form("radiobutton")) 

education = request.form("radiobutton").ToString(); 

を交換する場合、これはあなたの最初の500エラーを解決する必要があります。 Cstr()の囲みは実際には必要ではありませんが、文字列に変換するVBScriptの方法です。

あなたのラジオボタングループは、コーディングしても機能しません。あなたが元の提出された価値を維持しようとしているなら、あなたはこのようなことをすべきです。

<input type="radio" name="radiobutton" value="1" <% If request.form("education") = "1" Then Response.write "checked" End if %> /> Some High School <br /> 
<input type="radio" name="radiobutton" value="2" <% If request.form("education") = "2" Then Response.write "checked" End if %> /> Completed high School <br /> 
<input type="radio" name="radiobutton" value="3" <% If request.form("education") = "3" Then Response.write "checked" End if %> />Some College Education <br /> 
<input type="radio" name="radiobutton" value="4" <% If request.form("education") = "4" Then Response.write "checked" End if %>/> Completed a B.S Degree <br /> 
<input type="radio" name="radiobutton" value="5" <% If request.form("education") = "5" Then Response.write "checked" End if %>/> Completed a Master Degree <br /> <br/> 

私は自分自身に、フォームのポストを持っているとエラーメッセージが横に表示させるために条件文を使用して、別のページに第二の形式を有するフォームの検証を行うための最善の方法ではないことを良くお勧めしたいです個々のフォーム要素が空であれば何も表示されません。

最後に、このページを見ると、Classic ASPで便利なエラーメッセージを有効にする方法が説明されています。 http://www.chestysoft.com/asp-error-messages.asp

関連する問題