Dinamik C # asp.net bir sayfa oluşturarak (php örnek dahil)

1 Cevap

I'm working from some sample code, provided in PHP - we are using c#, so i'm having to convert it. Basically, it requires that i submit a bunch of data to an API, which returns an xml document as a response.

Daha sonra aşağıdaki HTML sahip bir sayfasına yönlendirmek gerekir:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Redirect Test Page</title>
</head>
<body OnLoad="OnLoadEvent();" >

<form name="downloadForm" action="ACS_URL_GOES_HERE" method="POST">
    <input type="hidden" name="PaReq" value="PAREQ_GOES_HERE">
    <input type="hidden" name="TermUrl" value="TERM_URL_GOES_HERE">
    <input type="hidden" name="MD" value="MD_GOES_HERE">
<noscript>
    <center>
    	<h1>Processing your 3-D Secure Transaction</h1>
    	<h2>JavaScript is currently disabled or is not supported by your browser.</h2><br>
    	<h3>Please click on the Submit button to continue the processing of your 3-D secure transaction.</h3>
    	<input type="submit" value="Submit">
    </center>
</noscript>
</form>
<script language="Javascript" >
<!--    
function OnLoadEvent(){
    document.downloadForm.target = "myIframe";
    document.downloadForm.submit();
}
//-->
</script>
<hr>
<iframe src="blank.htm" name="myIframe" width="390" height="450" frameborder="0">
</iframe>
<hr>

</body>
</html>

(_GOES_HERE Biten Büyük harf değişkenleri () Yukarıdaki yanıt XML belgesinden geçirilen olacak)

Kez yüklenir Bu sayfa, gönderir ve iFrame içinde sonuç koyar - "myIframe" olarak adlandırılan

Bu temelde bu!

I'm having great trouble doing something like this in C# - in PHP: they have this:

function RedirectToACSPage ($doc, $data_set) {
// error_log ("Call RedirectToACSPage");
// error_log ($doc->get("Response.CardTxn.ThreeDSecure.pareq_message"));
$pareq = $doc->get("Response.CardTxn.ThreeDSecure.pareq_message");
$acs_url = $doc->get("Response.CardTxn.ThreeDSecure.acs_url");
// $acs_url = "http://staging.datacash.com/ops/cgi/args.php";

// error_log ("PAREQ: " . $pareq);
// error_log ("ACS URL: " . $acs_url);
$term_url = "https://staging.datacash.com/ops/tester/next.php";
$md = $doc->get("Response.datacash_reference") . ":" . $data_set{'vtid'} . ":" .     $data_set{'password'} . ":" . $data_set{'tran_type'} . ":" . $data_set{'url'}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Redirect Test Page</title>
</head>
<body OnLoad="OnLoadEvent();" >

<form name="downloadForm" action="<?php echo $acs_url ?>" method="POST">
    <input type="hidden" name="PaReq" value="<?php echo $pareq ?>">
    <input type="hidden" name="TermUrl" value="<?php echo $term_url ?>">
    <input type="hidden" name="MD" value="<?php echo $md ?>">
<noscript>
    <center>
    	<h1>Processing your 3-D Secure Transaction</h1>
    	<h2>JavaScript is currently disabled or is not supported by your browser.    </h2><br>
	<h3>Please click on the Submit button to continue the processing of your 3-D secure transaction.</h3>
	<input type="submit" value="Submit">
</center>
</noscript>
</form>
<script language="Javascript" >
<!--    
function OnLoadEvent(){
    document.downloadForm.target = "joe";
    document.downloadForm.submit();
}
//-->
</script>



1 Cevap

Vay bunu yapıyorsun yolu PHP mantıklı olabilir ama kadarıyla bu ne kullandığınız varsayarak webforms alabilirsiniz gibidir.

PHP ile aşina iseniz ben web formlari üzerinde fakat siz zaten web formlari yolda başladım ne söylediğini sesi ASP.Net MVC kullanarak öneriyoruz.

Javascript ile size zaman kazandıracak, çünkü orada ne var alarak ve çalışacak bir şeye dönüştürerek basit yolu jQuery kullanmaya başlamak için ilk, sonra aspx gelen OnLoadEvent işlev kaldırmak ve bunu kaydetmek için komut yöneticisini kullanın edin arkasında kod. Lütfen javascript fonksiyonu sonra göndermeden önce gizli alanların değerini değiştirebilirsiniz.

Although having said that, you are better off redesigning the page to work better with asp.net webforms. You could have the entire flow done on one page if necessary, using updatepanels or postbacks to update the screen. I'd recommend having a look at sample asp.net code and seeing how flow is handled because it's very different and will take a bit of getting used to.