Here is a simple way to use iframe in asp.net. In responding to a Chinese asp.net forum question, I write the following code to direct a new page to the iframe when clicking a button.
Here’s the sample code I write with VS2008.
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script type="text/javascript">
function Buton1ClientClick()
{
document.forms["form2"].submit();
}
</script>
<script runat="server">
protected void Button1_Click(object sender, EventArgs e)
Response.Write("adsf");
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="Button1" runat="server" Text="Button"
OnClientClick="Buton1ClientClick();" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
<form id="form2" action="webForm2.aspx" target="test">
<iframe name="test" src="webForm1.aspx"></iframe>
</body>
</html>
This code only demonstrated one of the simple ways to handle <iframe> post in a button. I don’t personally recommend this way. I recommend using of AJAX directly without <iframe>, or use http://www.codeplex.com/UFrame .
===
中文
这是在asp.net中一个使用iframe的简单方式。我在回答一个中文asp.net论坛问题时,写了上面的简单页面,点击按钮来改变iframe里的页面显示。页面在VS2008中生成。 这段程序只是显示了一个简单的方式,我个人并不推荐使用。我推荐直接使用AJAX,或者使用 http://www.codeplex.com/UFrame .