2012-06-25 4 views
0

아래보기와 같이 DomainConfirmationView라는 PostToPalPal 뷰가 두 개 있습니다. DomainConfirmationView에는 PostToPayPal에 링크되어있는 버튼이 있습니다.이 버튼은 게시 이벤트를 통해 페이팔로 리디렉션됩니다. 내가 가지고있는 문제는이 버튼을 클릭 할 때 아무것도하지 않는다는 것입니다. 나는 다른 페이지에서이 작업을하고 있지만 페이지 상단에는 @model dynamic 밖에 없었고 나머지는 HTML이었다. 누구든지 내가 잘못 가고있는 생각이 있습니까? 죄송합니다. 이것이 정말로 멍청한 것이라면, 이것은 MVC에서 처음입니다.보기 간 연결

감사

@model application.Models.PayPal 

@{ 
    Layout = null; 
} 

<!DOCTYPE html> 
<html> 
<head> 
    <title>Index</title> 
    <script src="@Url.Content("~/Scripts/jquery-1.6.2.min.js")" type="text/javascript"></script> 
</head> 
<body> 
    <form id="frm" [email protected]> 
    @Html.HiddenFor(model => model.cmd) 
    @Html.HiddenFor(model => model.business) 
    @Html.HiddenFor(model => model.no_shipping) 
    @Html.HiddenFor(model => [email protected]) 
    @Html.HiddenFor(model => model.cancel_return) 
    @Html.HiddenFor(model => model.notify_url) 
    @Html.HiddenFor(model => model.currency_code) 
    @Html.HiddenFor(model => model.item_name) 
    @Html.HiddenFor(model => model.amount) 
    </form> 
    <p style="text-align: center"> 
     <h4> 
      <img src="../../Images/New-LogoPNG.png" /> 
      <br /> 
      You are now being redirected to Paypal...</h4> 
    </p> 
</body> 
</html> 
<script type="text/javascript" language="javascript"> 
    $(this.document).ready(function() { 
     var frm = $("form"); 
     frm.submit(); 
    }); 
</script> 

DomainConfirmationView

@model Application.Models.DomainCustomerDetails 
@using (Html.BeginForm("PostToPayPal", "Home")) 
{ 
<input type ="hidden" name="item" value= ".com"/> 
<input type = "hidden" name="amount" value="10" /> 

} 
@{ 
    ViewBag.Title = "Domain order placed"; 
} 

    @{ 
     String Input = "Hi" +".&lt;BR /&gt;&lt;BR /&gt;" 
      + "You have a new domain order that has been placed." 
      + "&lt;BR /&gt;&lt;BR /&gt;" 
      + "Domain Details" 
      + "&lt;BR /&gt;&lt;BR /&gt;" 
      + "Domain name:" + Model.DomainName 
      + "&lt;BR /&gt;&lt;BR /&gt;" 
      + "Domain duration " + Model.DomainDuration 
      + "&lt;BR /&gt;&lt;BR /&gt;" 
      + "Domain order type" + Model.OrderType 
      + "&lt;BR /&gt;&lt;BR /&gt;" 
      + "&lt;BR /&gt;&lt;BR /&gt;" 
      + Model.FirstName 
      + "&lt;BR /&gt;&lt;BR /&gt;" 
      + Model.LastName 
      + "&lt;BR /&gt;&lt;BR /&gt;" 
      + Model.BusinessName 
      + "&lt;BR /&gt;&lt;BR /&gt;" 
      + Model.Address 
      + "&lt;BR /&gt;&lt;BR /&gt;" 
      + Model.Address2 
      + "&lt;BR /&gt;&lt;BR /&gt;" 
      + Model.PostalCode 
      + "&lt;BR /&gt;&lt;BR /&gt;" 
      + Model.EmailAddress 
      + "&lt;BR /&gt;&lt;BR /&gt;" 
      + Model.ContactNumber 
      + "&lt;BR /&gt;&lt;BR /&gt;" 
      + "&lt;BR /&gt;&lt;BR /&gt;" 
      + "Kind regards" 
      + "&lt;BR /&gt;&lt;BR /&gt;" 
      + "xxx" 
      + "&lt;BR /&gt;&lt;BR /&gt;" 
      + "Email: [email protected]" 
      + "&lt;BR /&gt;&lt;BR /&gt;"; 

     String Output = Server.HtmlDecode(Input); 

      WebMail.SmtpServer = "mail.xxx.com"; 
      WebMail.SmtpPort = 25; 
      WebMail.EnableSsl = false; 
      WebMail.UserName = "[email protected]"; 
      WebMail.Password = "xxxx"; 
      WebMail.From = "[email protected]"; 
      WebMail.Send("[email protected]", "You have a new domain order " + Model.DomainName,Output); 



    } 

    @{ 
     String Inputorder = "Hi " + Model.FirstName 
      + "&lt;BR /&gt;&lt;BR /&gt;" 
      + "We are pleased to say your domain name " + Model.DomainName + "has been ordered." 
      + "&lt;BR /&gt;&lt;BR /&gt;" 
      + "Domain Details" 
      + "&lt;BR /&gt;&lt;BR /&gt;" 
      + Model.DomainName 
      + "&lt;BR /&gt;&lt;BR /&gt;" 
      + "Domain duration" + Model.DomainDuration 
      + "&lt;BR /&gt;&lt;BR /&gt;"  
      + "What to do next" 
      + "&lt;BR /&gt;&lt;BR /&gt;" 
      + "Server IP" 
      + "&lt;BR /&gt;&lt;BR /&gt;" 
      +"Name Server 1:" 
      + "&lt;BR /&gt;&lt;BR /&gt;" 
      +"Name Server 2:" 
      + "&lt;BR /&gt;&lt;BR /&gt;" 
      +"MX:" 
      + "&lt;BR /&gt;&lt;BR /&gt;" 
      +"A:" 
      + "&lt;BR /&gt;&lt;BR /&gt;" 
      +"CNAME:" 
      + "&lt;BR /&gt;&lt;BR /&gt;" 
      + "PLEASE NOTE" 
      + "&lt;BR /&gt;&lt;BR /&gt;" 
      + "Please allow 24 hours for any DNS changes to take effect due to DNS caching by your ISP." 
      + "&lt;BR /&gt;&lt;BR /&gt;" 
      + "Many thanks for your order" 
      + "&lt;BR /&gt;&lt;BR /&gt;" 
      + "Kind regards" 
      + "&lt;BR /&gt;&lt;BR /&gt;" 
      + "xxx" 
      + "&lt;BR /&gt;&lt;BR /&gt;" 
      + "Email: [email protected]" 
      + "&lt;BR /&gt;&lt;BR /&gt;"; 


     String Outputorder = Server.HtmlDecode(Inputorder); 

      WebMail.SmtpServer = "mail.xxx.com"; 
      WebMail.SmtpPort = 25; 
      WebMail.EnableSsl = false; 
      WebMail.UserName = "[email protected]"; 
      WebMail.Password = "xxx"; 
      WebMail.From = "[email protected]"; 

      WebMail.Send(Model.EmailAddress, "Your new domain order: " + Model.DomainName,Outputorder); 



    } 



<p>Thank you, almost done</p> 

<p>Please click the purchase button to continue</p> 
<input type ="submit" name="btsubmit" value= "Purchase"/> 

I also have a controller called DomainsController 



     [HttpPost] 
      public ActionResult PostToPayPal(string item, string amount) 
      { 
       YippeeYay.Models.PayPal paypal = new Models.PayPal(); 
       paypal.cmd = "_xclick"; 
       paypal.business = ConfigurationManager.AppSettings["BusinessAccountKey"]; 

       bool useSandbox = Convert.ToBoolean(ConfigurationManager.AppSettings["UseSandbox"]); 
       if (useSandbox) 
        ViewBag.actionURL = "https://www.sandbox.paypal.com/cgi-big/webscr"; 
       else 
        ViewBag.actionURL = "https://www.paypal.com/cgi-bin/webscr"; 

       paypal.cancel_return = System.Configuration.ConfigurationManager.AppSettings["CancelURL"]; 
       [email protected] = ConfigurationManager.AppSettings["ReturnURL"]; 
       paypal.notify_url = ConfigurationManager.AppSettings["NotifyURL"]; 

       paypal.currency_code = ConfigurationManager.AppSettings["CurrencyCode"]; 

       paypal.item_name = item; 
       paypal.amount = amount; 
       return View(paypal); 
      } 

답변

1

이 섹션 :

@using(Html.BeginForm("PostToPayPal", "Home")) 
{ 
    // Form goes in here 
} 

은 ... 당신의 제출 버튼을 포함 할 필요가 태그를 쓰고 것입니다. 현재 제출 버튼은 외부 인이므로이 양식에있는 두 가지 숨겨진 필드 만 있습니다. 양식 안에 제출 버튼을 이동하면 제대로 작동합니다.

+0

그렉 덕분에 잘됐다! 느낌이 간단했다. – Steve