I have a page in VB ASP.NET with the following code (this was generated by VS):
我在VB ASP.NET中有一个页面,其中包含以下代码(这是由VS生成的):
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Payment2.aspx.vb" Inherits="Payment2" %>
<!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 runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
With code
用代码
Partial Class Payment2
Inherits System.Web.UI.Page
Sub Page_Load(ByVal S As Object, ByVal E As EventArgs)
End Sub
End Class
And I want to be able to inject the following String into the page and display.
我希望能够将以下String注入页面并显示。
<form name="downloadform3D" action="https://something.asp" method="post">
<NOSCRIPT>
JavaScript is currently disabled or is not supported by your browser.<br>
Please click on the "Continue" button to continue<br>
<input class="ncol" type="submit" value="Continue" id="submit1" name="submit1" />
</NOSCRIPT>
<input type="hidden" name="CSRFKEY" value="abc" />
<input type="hidden" name="CSRFTS" value="abc" />
<input type="hidden" name="CSRFSP" value="/ncol/test/something.asp" />
<input type="hidden" name="PaReq" value="<?xml version="1.0"?><ThreeDSecure><Message id="123"><PAReq><version>1.02</version><Merchant><merID>abc</merID><name>abc</name><url>http://www.abc.com</url></Merchant><Purchase><xid>123</xid><amount>1</amount><purchAmount>1</purchAmount><currency>GBP</currency></Purchase><CH><acctID>12345</acctID><expiry>1234</expiry><selBrand></selBrand></CH></PAReq></Message></ThreeDSecure>
" />
<input type="hidden" name="TermUrl" value="https://something.asp" />
<input type="hidden" name="MD" value="12334" />
</form>
<form method="post" action="https://somethig.asp" name="uploadForm3D">
<input type="hidden" name="CSRFKEY" value="1234A" />
<input type="hidden" name="CSRFTS" value="1234" />
<input type="hidden" name="CSRFSP" value="/something.asp" />
<input type="hidden" name="branding" value="abc" />
</form>
<SCRIPT LANGUAGE="Javascript" >
<!--
var popupWin;
var submitpopupWin = 0;
function LoadPopup() {
if (self.name == null) {
self.name = "ogoneMain";
}
popupWin = window.open('about:blank', 'popupWin', 'height=400, width=390, status=yes, dependent=no, scrollbars=yes, resizable=no');
if (popupWin != null) {
if (!popupWin || popupWin.closed) {
return 1;
} else {
if (!popupWin.opener || popupWin.opener == null) {
popupWin.opener = self;
}
self.document.forms.downloadform3D.target = 'popupWin';
if (submitpopupWin == 1) {
self.document.forms.downloadform3D.submit();
}
popupWin.focus();
return 0;
}
} else {
return 1;
}
}
self.document.forms.downloadform3D.submit();
//-->
</SCRIPT>
I've had a look on google but nothing has helped (I may be entering the wrong search terms as I'm new to web programming). Any help would be really appreciated as I'm not an ASP guy and I've been pulling out what little hair I have left now for 3 days :(
我已经看过谷歌,但没有任何帮助(我可能会输入错误的搜索条件,因为我是网络编程的新手)。任何帮助都会非常感激,因为我不是一个ASP人,而且我已经拉出了我现在留下3天的小头发:(
Thanks in advance.
提前致谢。
3 个解决方案
#1
1
you can do Response.Write,
你可以做Response.Write,
or
要么
you can use asp:Literal
你可以使用asp:Literal
there are a few modes with the asp:Literal control
asp:Literal控件有几种模式
PassThrough renders the content "as is" including html markup and script. This is a bad idea if you don't complely control the output. If you are dynamically including anythin that would be taken from user input or values stored in database you could put yourself at security risk.
PassThrough“按原样”呈现内容,包括html标记和脚本。如果您不完全控制输出,这是一个坏主意。如果您动态地包含将从用户输入中获取的任何内容或存储在数据库中的值,您可能会面临安全风险。
Encode is HTML encoded. Its treated like text not HTML so this wont work for you
编码是HTML编码的。它被视为文本而不是HTML,所以这对你不适用
Transform tries to change the markup to match the browser which may or may not work.
转换尝试更改标记以匹配可能或可能不起作用的浏览器。
Another option is to use a user control and set its "Visible" property on demand.
另一种选择是使用用户控件并根据需要设置其“可见”属性。
#2
2
From your question it seems that you're trying to insert the string from server side, but I think it's better to do it in the aspx page itself.
从您的问题看来,您似乎正在尝试从服务器端插入字符串,但我认为最好在aspx页面本身中执行此操作。
Remove this code from the aspx page:
从aspx页面中删除此代码:
<form id="form1" runat="server">
<div>
</div>
</form>
and put your code in instead. It should look like this:
并改为使用代码。它应该如下所示:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Payment2.aspx.vb" Inherits="Payment2" %>
<!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 runat="server">
<title></title>
</head>
<body>
<form name="downloadform3D" action="https://something.asp" method="post">
<NOSCRIPT>
JavaScript is currently disabled or is not supported by your browser.<br>
Please click on the "Continue" button to continue<br>
<input class="ncol" type="submit" value="Continue" id="submit1" name="submit1" />
</NOSCRIPT>
<input type="hidden" name="CSRFKEY" value="abc" />
<input type="hidden" name="CSRFTS" value="abc" />
<input type="hidden" name="CSRFSP" value="/ncol/test/something.asp" />
<input type="hidden" name="PaReq" value="<?xml version="1.0"?><ThreeDSecure><Message id="123"><PAReq><version>1.02</version><Merchant><merID>abc</merID><name>abc</name><url>http://www.abc.com</url></Merchant><Purchase><xid>123</xid><amount>1</amount><purchAmount>1</purchAmount><currency>GBP</currency></Purchase><CH><acctID>12345</acctID><expiry>1234</expiry><selBrand></selBrand></CH></PAReq></Message></ThreeDSecure>
" />
<input type="hidden" name="TermUrl" value="https://something.asp" />
<input type="hidden" name="MD" value="12334" />
</form>
<form method="post" action="https://somethig.asp" name="uploadForm3D">
<input type="hidden" name="CSRFKEY" value="1234A" />
<input type="hidden" name="CSRFTS" value="1234" />
<input type="hidden" name="CSRFSP" value="/something.asp" />
<input type="hidden" name="branding" value="abc" />
</form>
<SCRIPT LANGUAGE="Javascript" >
<!--
var popupWin;
var submitpopupWin = 0;
function LoadPopup() {
if (self.name == null) {
self.name = "ogoneMain";
}
popupWin = window.open('about:blank', 'popupWin', 'height=400, width=390, status=yes, dependent=no, scrollbars=yes, resizable=no');
if (popupWin != null) {
if (!popupWin || popupWin.closed) {
return 1;
} else {
if (!popupWin.opener || popupWin.opener == null) {
popupWin.opener = self;
}
self.document.forms.downloadform3D.target = 'popupWin';
if (submitpopupWin == 1) {
self.document.forms.downloadform3D.submit();
}
popupWin.focus();
return 0;
}
} else {
return 1;
}
}
self.document.forms.downloadform3D.submit();
//-->
</SCRIPT>
</body>
</html>
#3
0
Did you tried Response.Write(contents); in the Page_Load event. Where contents is the data you want to inject to the Page.
你有没有尝试过Response.Write(内容);在Page_Load事件中。内容是您要向页面注入的数据。
#1
1
you can do Response.Write,
你可以做Response.Write,
or
要么
you can use asp:Literal
你可以使用asp:Literal
there are a few modes with the asp:Literal control
asp:Literal控件有几种模式
PassThrough renders the content "as is" including html markup and script. This is a bad idea if you don't complely control the output. If you are dynamically including anythin that would be taken from user input or values stored in database you could put yourself at security risk.
PassThrough“按原样”呈现内容,包括html标记和脚本。如果您不完全控制输出,这是一个坏主意。如果您动态地包含将从用户输入中获取的任何内容或存储在数据库中的值,您可能会面临安全风险。
Encode is HTML encoded. Its treated like text not HTML so this wont work for you
编码是HTML编码的。它被视为文本而不是HTML,所以这对你不适用
Transform tries to change the markup to match the browser which may or may not work.
转换尝试更改标记以匹配可能或可能不起作用的浏览器。
Another option is to use a user control and set its "Visible" property on demand.
另一种选择是使用用户控件并根据需要设置其“可见”属性。
#2
2
From your question it seems that you're trying to insert the string from server side, but I think it's better to do it in the aspx page itself.
从您的问题看来,您似乎正在尝试从服务器端插入字符串,但我认为最好在aspx页面本身中执行此操作。
Remove this code from the aspx page:
从aspx页面中删除此代码:
<form id="form1" runat="server">
<div>
</div>
</form>
and put your code in instead. It should look like this:
并改为使用代码。它应该如下所示:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Payment2.aspx.vb" Inherits="Payment2" %>
<!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 runat="server">
<title></title>
</head>
<body>
<form name="downloadform3D" action="https://something.asp" method="post">
<NOSCRIPT>
JavaScript is currently disabled or is not supported by your browser.<br>
Please click on the "Continue" button to continue<br>
<input class="ncol" type="submit" value="Continue" id="submit1" name="submit1" />
</NOSCRIPT>
<input type="hidden" name="CSRFKEY" value="abc" />
<input type="hidden" name="CSRFTS" value="abc" />
<input type="hidden" name="CSRFSP" value="/ncol/test/something.asp" />
<input type="hidden" name="PaReq" value="<?xml version="1.0"?><ThreeDSecure><Message id="123"><PAReq><version>1.02</version><Merchant><merID>abc</merID><name>abc</name><url>http://www.abc.com</url></Merchant><Purchase><xid>123</xid><amount>1</amount><purchAmount>1</purchAmount><currency>GBP</currency></Purchase><CH><acctID>12345</acctID><expiry>1234</expiry><selBrand></selBrand></CH></PAReq></Message></ThreeDSecure>
" />
<input type="hidden" name="TermUrl" value="https://something.asp" />
<input type="hidden" name="MD" value="12334" />
</form>
<form method="post" action="https://somethig.asp" name="uploadForm3D">
<input type="hidden" name="CSRFKEY" value="1234A" />
<input type="hidden" name="CSRFTS" value="1234" />
<input type="hidden" name="CSRFSP" value="/something.asp" />
<input type="hidden" name="branding" value="abc" />
</form>
<SCRIPT LANGUAGE="Javascript" >
<!--
var popupWin;
var submitpopupWin = 0;
function LoadPopup() {
if (self.name == null) {
self.name = "ogoneMain";
}
popupWin = window.open('about:blank', 'popupWin', 'height=400, width=390, status=yes, dependent=no, scrollbars=yes, resizable=no');
if (popupWin != null) {
if (!popupWin || popupWin.closed) {
return 1;
} else {
if (!popupWin.opener || popupWin.opener == null) {
popupWin.opener = self;
}
self.document.forms.downloadform3D.target = 'popupWin';
if (submitpopupWin == 1) {
self.document.forms.downloadform3D.submit();
}
popupWin.focus();
return 0;
}
} else {
return 1;
}
}
self.document.forms.downloadform3D.submit();
//-->
</SCRIPT>
</body>
</html>
#3
0
Did you tried Response.Write(contents); in the Page_Load event. Where contents is the data you want to inject to the Page.
你有没有尝试过Response.Write(内容);在Page_Load事件中。内容是您要向页面注入的数据。