简体   繁体   English

将动态HTML内容写入页面或弹出窗口

[英]Write Dynamic Html Content to Page or Popup

I have C# asp.net Web Forms project.I am using credit card payment system which returns me html code for 3d payment page (not redirecting auto). 我有C#asp.net Web窗体项目。我正在使用信用卡付款系统,该系统向我返回3d付款页面的html代码(不自动重定向)。 Here is my request's ; 这是我的要求;

                thirdBasketItem.Price = "0.2";
                basketItems.Add(thirdBasketItem);
                request.BasketItems = basketItems;

                ThreedsInitialize threedsInitialize = ThreedsInitialize.Create(request, options);
                var dynamicHtml = threedsInitialize.HtmlContent;

and here is my dynamicHtml variable value ; 这是我的dynamicHtml变量值;

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
 <head> 
  <title>MDpay default response template for web</title> 
 </head> 
 <body onload="OnLoadEvent();"> 
  <form name="downloadForm" action="https://acs.bkm.com.tr/mdpayacs/pareq" method="POST"> 
   <input type="hidden" name="PaReq" value="eJxdUl1P4zAQfOdXRHm/+KNO2yDXiEIRfeAEpXDiMefsUUskKU5ybfn1t07rc0oURd6Z8e5mduXV
vvyI/oJtTF3NYpbQOIJK14Wp3mfxy/ruxzS+UhdyvbEAt8+gOwvqIorkAzRN/g6RKfDWeCwYz0Qa
OwrJx+sVfB7PGJ2yK0yecEl86OkH+iJvQXHKJhQ/EZtephRf
SXp8YFrpulbr1VvEEo78CQiKrevl+ogypxgCAys6a3EHDioTGXrhoyCA/bauAO+gVf/Pg36h0REJ
nny3QN7cn81atzi1MR+NGJ+K1I27R87qGZwGH1PRFzRhNJL4ZFjHb50bQ7+duLjkfHP/AT7Qy6g=" /> 
   <input type="hidden" name="TermUrl" value="https://sanalpos.teb.com.tr/fim/est3Dgate?msgid=16945" /> 
   <input type="hidden" name="MD" value="402591:30D0FEDACD3047305C8E24EBC3739AC3E87C8:4273:##400644452" /> 
   <!-- To support javascript unaware/disabled browsers --> 
   <div style="text-align: center;"> 
    <img src="templates/preloader.gif" />
    <br /> 
    <noscript> 
     <center>
      Please click the submit button below.
      <br /> 
      <input type="submit" name="submit" value="Submit" />
     </center> 
    </noscript> 
   </div> 
  </form> 
  <script language="Javascript">
  function OnLoadEvent() {
    document.downloadForm.submit();
  }
</script>  
 </body>
</html>

How can I write this content on popup or another window to show customer ? 如何在弹出窗口或其他窗口上显示此内容以显示客户?

I think a better solution is to generate a redirect with post, and I've done this with 3D Security payments and it works for me 我认为一个更好的解决方案是使用post生成重定向,而我使用3D安全付款完成了此操作,并且对我有用

 NameValueCollection data = new NameValueCollection();

data.Add("PaReq", "eJxdUl1P4zAQfOdXRHm/+KNO2yDXiEIRfeAEpXDiMefsUUskKU5ybfn1t07rc0oURd6Z8e5mduXV
vvyI/oJtTF3NYpbQOIJK14Wp3mfxy/ruxzS+UhdyvbEAt8+gOwvqIorkAzRN/g6RKfDWeCwYz0Qa
OwrJx+sVfB7PGJ2yK0yecEl86OkH+iJvQXHKJhQ/EZtephRf
SXp8YFrpulbr1VvEEo78CQiKrevl+ogypxgCAys6a3EHDioTGXrhoyCA/bauAO+gVf/Pg36h0REJ
nny3QN7cn81atzi1MR+NGJ+K1I27R87qGZwGH1PRFzRhNJL4ZFjHb50bQ7+duLjkfHP/AT7Qy6g=");

data.Add("TermUrl", "https://sanalpos.teb.com.tr/fim/est3Dgate?msgid=16945");

data.Add("MD", "402591:30D0FEDACD3047305C8E24EBC3739AC3E87C8:4273:##400644452");
RedirectAndPOST(this.Page, "https://acs.bkm.com.tr/mdpayacs/pareq", data);


    /// <summary>
    /// POST data and Redirect to the specified url using the specified page.
    /// </summary>
    /// <param name="page">The page which will be the referrer page.</param>
    /// <param name="destinationUrl">The destination Url to which
    /// the post and redirection is occuring.</param>
    /// <param name="data">The data should be posted.</param>
    /// <Author>Samer Abu Rabie</Author>

    public static void RedirectAndPOST(Page page, string destinationUrl,
                                       NameValueCollection data)
    {
        //Prepare the Posting form
        string strForm = PreparePOSTForm(destinationUrl, data);
        //Add a literal control the specified page holding 
        //the Post Form, this is to submit the Posting form with the request.
        page.Controls.Add(new LiteralControl(strForm));
    }

    /// <summary>
    /// This method prepares an Html form which holds all data
    /// in hidden field in the addetion to form submitting script.
    /// </summary>
    /// <param name="url">The destination Url to which the post and redirection
    /// will occur, the Url can be in the same App or ouside the App.</param>
    /// <param name="data">A collection of data that
    /// will be posted to the destination Url.</param>
    /// <returns>Returns a string representation of the Posting form.</returns>
    /// <Author>Samer Abu Rabie</Author>
    private static String PreparePOSTForm(string url, NameValueCollection data)
    {
        //Set a name for the form
        string formID = "PostForm";
        //Build the form using the specified data to be posted.
        StringBuilder strForm = new StringBuilder();
        strForm.Append("<form id=\"" + formID + "\" name=\"" +
                       formID + "\" action=\"" + url +
                       "\" method=\"POST\">");

        foreach (string key in data)
        {
            strForm.Append("<input type=\"hidden\" name=\"" + key +
                           "\" value=\"" + data[key] + "\">");
        }

        strForm.Append("</form>");
        //Build the JavaScript which will do the Posting operation.
        StringBuilder strScript = new StringBuilder();
        strScript.Append("<script language='javascript'>");
        strScript.Append("var v" + formID + " = document." +
                         formID + ";");
        strScript.Append("v" + formID + ".submit();");
        strScript.Append("</script>");
        //Return the form and the script concatenated.
        //(The order is important, Form then JavaScript)
        return strForm.ToString() + strScript.ToString();
    }

https://www.codeproject.com/Articles/37539/Redirect-and-POST-in-ASP-NET https://www.codeproject.com/Articles/37539/Redirect-and-POST-in-ASP-NET

First, you will most likely need to clean up the html a little bit. 首先,您很可能需要清理html一点。

Second, you can render html in a webforms .aspx page by using a literal control and setting the html to the Text property: 其次,可以通过使用文字控件并将html设置为Text属性来在webforms .aspx页面中呈现html:

<asp:Literal ID="Literal1"
        Mode="PassThrough"
        Text= "Your HTML"          
        runat="server">
    </asp:Literal>

Here is more information from msdn: literal control 这是来自msdn的更多信息: 文字控制

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM