Ftp using filezilla in asp.net - asp-classic

i have created this file in visual studio 2012 . The first page of survey works completely fine but when it re directs to display its showing '500 internal server error. The project has no compilation error . i am opening this file using filezilla can anyone please help me . its a simple program which fetches the value from survey.asp and displays the value in the next form in a tabular format.
------ 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>

This is classic asp with vbscript, not asp.net with C#. You don't get compilation errors with classic because it isn't compiled, it's interpreted at runtime.
You appear to have put a line of C# in display.asp - if you replace the line
education = request.form("radiobutton").ToString();
with
education = Cstr(request.form("radiobutton"))
This should solve your initial 500 error. Enclosing within Cstr() isn't actually necessary, but it's the VBScript way of converting to a string.
I don't think your radio button group will work as you have coded it. If you're trying to preserve the original submitted value you should do something like this.
<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/>
I'd suggest that having a second form on a different page isn't the best way to do form validation, better to have the form post to itself and use conditional statements to make error messages appear beside the individual form elements if nothing if they're left empty.
Finally, look at this page - it tells you how to enable useful error messages in Classic ASP.
http://www.chestysoft.com/asp-error-messages.asp

Related

Paypal Form Tag issue in asp.net

Hello guys i have gatting issue on loading asp.net
i have using master page for sub pages there is a form tag in materpage i have add a paypal button in sub page which is this in master page form tag is also important
in masterpage <form id="form1" runat="server"></form>
and in sup age
<form id="form2" runat="server" name="Paypal" action="https://www.paypal.com/cgi-bin
/webscr"
method="post">
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="upload" value="1" />
<input type="hidden" name="business" value="
<%=System.Web.Configuration.WebConfigurationManager.AppSettings["email"] %>
" />
<input type="hidden" name="item_name_1" value="<%=Session["ItemName"].ToString()%>"
/>
<input type="hidden" name="amount_1" value="<%=Session["ItemCost"].ToString() %>"/>
<input type="hidden" name="quantity_1" value="1" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="return" value="<%=Session["returnUrl"].ToString() %>"/>
<input type="hidden" name="lc" value="Stronger" />
<input type="image" src="images/paynow.png" border="0" name="submit" alt="Make
payments with PayPal - it's fast, free and secure!"
style="background: url(images/update-account.png);"/>
</form>
I'm getting bug this with sub page below
Server Error in '/Project' Application.
A page can have only one server-side Form tag.
Description: An unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: A page can have only one server-side Form tag.
anybody have a idea how can i use form tag in sub page also.
Please check how many <form> tags are written on your aspx/html page. Make sure you are not using masterpage for this page.
Hi I have found this solution and its work solution is below:
<form name="Paypal" action="https://www.paypal.com/cgi-bin/webscr"
method="post" target="_blank"></form>
<form name="Paypal" action="https://www.paypal.com/cgi-bin/webscr"
method="post">
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="upload" value="1" />
<input type="hidden" name="business" value="
<%=System.Web.Configuration.WebConfigurationManager.AppSettings["email"] %>
" />
<input type="hidden" name="item_name_1" value="<%=Session["ItemName"].ToString()%>"
/>
<input type="hidden" name="amount_1" value="<%=Session["ItemCost"].ToString() %>"/>
<input type="hidden" name="quantity_1" value="1" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="return" value="<%=Session["returnUrl"].ToString() %>"/>
<input type="hidden" name="lc" value="Stronger" />
<input type="image" src="images/paynow.png" border="0" name="submit" alt="Make
payments with PayPal - it's fast, free and secure!"
style="background: url(images/update-account.png);"/>
</form>
This code is working good as i want.
If you'are under a MasterPage Don't use the form tag as long as you're inside a form, just delete it, delete the hidden input that causes the SUBMIT and, instead, use the following ImageButton:
<asp:ImageButton ID="cmdpay" runat="server" PostBackUrl="https://www.paypal.com/cgi-bin/webscr" Text="" ImageUrl="images/paynow.png" ></asp:ImageButton>
It works

Why <%if cars="Volvo" then Response.Write("checked")%>

I am kind a new to ASP and i see an example but can't figure out why using
<%if cars="Volvo" then Response.Write("checked")%>
Code:->
<!DOCTYPE html>
<html>
<%
dim cars
cars=Request.Form("cars")
%>
<body>
<form action="demo_radiob.asp" method="post">
<p>Please select your favorite car:</p>
<input type="radio" name="cars"
<%if cars="Volvo" then Response.Write("checked")%>
value="Volvo">Volvo</input>
<br>
<input type="radio" name="cars"
<%if cars="Saab" then Response.Write("checked")%>
value="Saab">Saab</input>
<br>
<input type="radio" name="cars"
<%if cars="BMW" then Response.Write("checked")%>
value="BMW">BMW</input>
<br><br>
<input type="submit" value="Submit" />
</form>
<%
if cars<>"" then
Response.Write("<p>Your favorite car is: " & cars & "</p>")
end if
%>
</body>
</html>
Any help would be appreciated
It is being used to make the radio button checked when output as HTML.
Here is more detailed explaination of the checked attribute - http://www.w3schools.com/tags/att_input_checked.asp
The response.write is printing out the string. Again here is a link to a more detailed explaination - http://www.w3schools.com/asp/met_write_response.asp
HTH
Wade

Login Control Issue

I'm a junior in a software engineering and web development class and have ran into a problem. I need a log in page so that after a user clicks the log in button, they will be sent to my actual web page. However, every time I click the log in button I recieve this error:
Server Error in '/Case04' Application.
Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster."
For this specific project, i am not concerned what the user enters as long as they enter information. I just need it so when the log in button is clicked i am sent to my actual web page which is pc.aspx.
Here is my Code:
<%# Page Language="C#" AutoEventWireup="true" CodeFile="Login.aspx.cs" Inherits="Login" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<link href="login.css" rel="stylesheet" type="text/css" />
<title></title>
</head>
<body>
<%--Heading--%>
<form name="c_order" id="c_order" runat="server"
action="pc.aspx" method="get">
<table>
<tr>
<td>
<img src="mclogog.jpg" alt="heading" id="heading" />
</td>
</tr>
</table>
<%--login--%>
<asp:Login ID="login" class="login" runat="server" size="10" maxlength="25" EventValidation="false"></asp:Login>
<p id="member" >Already a member?</p>
<%--fieldset for new user --%>
<fieldset>
<legend id="bill">Shipping Information</legend>
<label for="fname" >First Name<span>*</span></label>
<input type="text" name="fname" id="fname" size="27" />
<label for="lname"> Last Name<span>*</span></label>
<input type="text" name="lname" id="lname" size="27" />
<label for="address1">Address #1<span>*</span></label>
<input type="text" name="address1" id="address1" size="57" />
<label for="address2">Address #2</label>
<input type="text" name="address2" id="address2" size="57" />
<label for="city">City<span>*</span></label></td>
<input type="text" name="city" id="city" size="40" />
<label for="state">State<span>*</span> </label>
<input type="text" name="state" id="state" size="3" />
<label for="zip">ZIP<span>*</span> </label>
<input type="text" name="zip" id="zip" size="10" maxlength="10" />
<label for="country">Country<span>*</span></label>
<input type="text" name="country" id="country" size="40" value="United States" />
<p id="ast">
* = Required field, must be filled in.
</p>
</fieldset>
</form>
</body>
</html>
I would appreciate any help, thanks!
The problem is that your page is not handling its own events. You have your < form > tag set up to post-back its values to another page.
< form ... action="pc.aspx" ... /> but your page is really called login.aspx. So, when this form's content gets posted to pc.aspx, it can't decode the viewstate, because it didn't come from pc.aspx.cs. It came from a different page.
Remove the action attribute from your form tag. Like this:
<form name="c_order" id="c_order" runat="server" method="get">

asp.net request.form

public ActionResult DisplayCustomer()
{
Customer objCustomer = new Customer();
objCustomer.Id = Convert.ToInt16(Request.Form["Customerid"]);
objCustomer.CustomerCode = Request.Form["code"];
objCustomer.Amount = Convert.ToDouble(Request.Form["amount"]);
return View(objCustomer);
}
This is my action in controller(MVC 2 aspx):
<form action="DisplayCustomer" method="post">
Customer id:-
<input type="text" id="Customerid" /><br />
Customer Code:-
<input type="text" id="code" /><br />
Customer amount:-
<input type="text" id="amount" /><br />
<input type="submit" value="click here" />
</form>
This is the view. When someone hit the submit button it is directed to a new page:
<div>
<b> ID</b> <%= Model.Id %><br />
<b> Code </b><%=Model.CustomerCode %><br />
<b> Amount</b> <%=Model.Amount %><br />
</div>
I always get 0 in Id and Amount while blank in CustomerCode.
Any clue? Why this is happening? What is wrong?
Your issue here is that you set the id, and not the name. Set the name to get the post back value. Eg:
<input type="text" name="Customerid" />
read also: HTML input - name vs. id in the line "Used on form elements to submit information"

Trouble getting to PayPal Buy Now Buttons to work on a single page in ASP.NET

I confess I am a noob to asp.net and web forms. I'm having an issue incorporating a few PayPal Buy Now buttons on a single page. Basically, the problem is no matter which "Buy Now" button is clicked, the user is taken to paypal to buy the product represented by the last button on the page.
The code for my first button is something like this...
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="ABC123">
<asp:ImageButton runat="server" id="PPImageButton1" PostBackUrl="https://www.paypal.com/cgi-bin/webscr" ImageUrl="https://www.paypal.com/en_US/i/btn/btn_buynow_SM.gif"/>
My second button is similar to...
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="ABC456">
<asp:ImageButton runat="server" id="PPImageButton2" PostBackUrl="https://www.paypal.com/cgi-bin/webscr" ImageUrl="https://www.paypal.com/en_US/i/btn/btn_buynow_SM.gif"/>
How can I make the first button send value ABC123 to the PayPal service instead of ABC456?
Thanks in advance.
The POST content of a button is every input in the FORM tag that surrounds the submit button. So to have each button submit a separate set of hidden fields you need to wrap the button and the desired hidden fields in a separate form:
<form ... >
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="ABC123">
<asp:ImageButton runat="server" id="PPImageButton1" PostBackUrl="https://www.paypal.com/cgi-bin/webscr" ImageUrl="https://www.paypal.com/en_US/i/btn/btn_buynow_SM.gif"/>
</form>
<form ... >
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="ABC456">
<asp:ImageButton runat="server" id="PPImageButton1" PostBackUrl="https://www.paypal.com/cgi-bin/webscr" ImageUrl="https://www.paypal.com/en_US/i/btn/btn_buynow_SM.gif"/>
</form>
My noob solution for this was to cut each of the buy-it-now buttons and its associated fields out of the aspx page, and put each set in a separate html page.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>first button</title>
</head>
<body>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="paypal">
<input type="hidden" value="_s-xclick" name="cmd" /> <input type="hidden" value="???????" name="hosted_button_id" />
<table>
<tbody>
<tr>
<td><input type="hidden" value="Member name" name="on0" />Member name</td>
<td><input maxlength="60" size="30" name="os0" /></td></tr>
<tr>
<td><input type="hidden" value="Membership No. (if known)" name="on1" />Membership No. (if known)</td>
<td><input maxlength="60" size="6" name="os1" /></td></tr></tbody></table>
<input type="image" alt="PayPal - The safer, easier way to pay online." src="https://www.paypal.com/en_GB/i/btn/btn_cart_LG.gif" name="submit" /> <img height="1" alt="" src="https://www.paypal.com/en_GB/i/scr/pixel.gif" width="1" border="0"/> </form>
</body>
</html>
In the place in the aspx page where you removed the button and other fields, insert an iframe which points to the html page like this:
<iframe width="600" height="" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="mybuttonpage1.htm"></iframe>
It's not your button that sends the value - it's the form it's in, and/or the code behind it.
Could you:
Post the form code?
Post the code behind for this page?
Here is a solution the the multiple form problem when using PayPal with ASP.NET:
http://www.codersbarn.com/post/2008/03/08/Solution-to-ASPNET-Form-PayPal-Problem.aspx
I discuss several workarounds for the problems of inserting PayPal code into an ASP.NET page, and present a different approach in my article at http://blackbeltcoder.com/Articles/ecommerce/quick-and-dirty-buy-now-buttons-in-asp-net.
In the end, you don't need to use a form because PayPal allows you to use a regular anchor link.
I was able to get it to work by removing all the other button containers from the DOM in jQuery. Add a class to your container, and add a CssClass to the ImageButton, "PayPalImageButtons"
<div>
Buy This First Product Below
</div>
<div class="ManualPurchase PayPalButtons">
<input type="hidden" name="cmd" value="_s-xclick" />
<input type="hidden" name="hosted_button_id" value="ABC123" />
<asp:ImageButton CssClass="PayPalImageButtons" runat="server" id="PPImageButton1" PostBackUrl="https://www.paypal.com/cgi-bin/webscr" ImageUrl="https://www.paypal.com/en_US/i/btn/btn_buynow_SM.gif" />
</div>
<div>
Buy This Second Product Below
</div>
<div class="ManualPurchase PayPalButtons">
<input type="hidden" name="cmd" value="_s-xclick" />
<input type="hidden" name="hosted_button_id" value="ABC456" />
<asp:ImageButton CssClass="PayPalImageButtons" runat="server" id="PPImageButton1" PostBackUrl="https://www.paypal.com/cgi-bin/webscr" ImageUrl="https://www.paypal.com/en_US/i/btn/btn_buynow_SM.gif" />
</div>
and the jQuery
<script type="text/javascript">
function pageLoad() {
$(".PayPalImageButtons").click(function (e) {
$(this).parent().addClass("keep");
$(".PayPalButtons").not(".keep").remove();
});
}
</script>
My next step is dealing with the removed elements height and maybe a Please Wait dialog while the PayPal page is loaded

Resources