How to open a web site inside the webpage in c#

Many times, we want to show/open a website inside of web page, for this we need to use <iframe> control. We can open website/ web page to pass the url .
Source Code:-
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="iframe.aspx.cs" Inherits="iframe" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head runat="server">

    <title>open a website using iframe</title>
    <form id="form1" runat="server">
    <fieldset style="width:1024px;">
        <legend>Open a web site in iframe </legend>

        <asp:DropDownList ID="DropDownList1" runat="server">
        <asp:TextBox ID="txturl" runat="server" placeholder="Please enter your website url"></asp:TextBox>
        <asp:Button ID="btnsubmit" runat="server" Text="GO "
            onclick="btnsubmit_Click" />

    <iframe id="frame1" width="1024px" height="786px" runat="server" visible="false"/>

Code behind(C#):-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

public partial class iframe : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)


    protected void btnsubmit_Click(object sender, EventArgs e)
        HtmlControl frame1 = (HtmlControl)this.FindControl("frame1");
        frame1.Visible = true;
        string text = DropDownList1.Text + txturl.Text;
        frame1.Attributes["src"] = text;


How to open a web site inside the webpage in c# How to open a web site inside the webpage in c# Reviewed by NEERAJ SRIVASTAVA on 6:06:00 PM Rating: 5

No comments:

Powered by Blogger.