asp.net占位符-将内容加载到



给定以下代码。如何通过C#代码中的服务器onClick事件在占位符中显示另一个网页或内容;类似于现已失效的iframe。我倾向于通过服务器端代码(C#,asp.net 4.0)处理所有事件

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"></asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContentPlaceHolder" 
runat="Server">
   <asp:PlaceHolder runat="server" ID="PlaceHolder1">  
</asp:PlaceHolder>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="NavigationContentPlaceHolder" Runat="Server">
<uc1:NavigationUserControl runat="server" ID="NavigationUserControl" />
</asp:Content>

提前谢谢!

您可以使用WebClient从URI接收页面。(它也可以将内容发送到URI。)

<asp:Button runat="server" ID="Button1" OnClick="Button1_Click" 
   Text="Load Page"/>
<asp:PlaceHolder runat="server" ID="PlaceHolder1">
</asp:PlaceHolder>
protected void Button1_Click(object sender, EventArgs e)
{
    var uri = new Uri("http://www.stackoverflow.com");
    var result = new WebClient().DownloadString(uri);
    PlaceHolder1.Controls.Add(new LiteralControl(result));
}

相关内容

  • 没有找到相关文章

最新更新