Note:-
A framekiller is a technique used by web applications to prevent their web pages from being displayed within a frame. Thus, this type of URL not opened in the "iframe".
A framekiller is a technique used by web applications to prevent their web pages from being displayed within a frame. Thus, this type of URL not opened in the "iframe".
More Info :- https://en.wikipedia.org/wiki/Framekiller
Don't forget to add AjaxControlToolkit dll in your project.
To download the AjaxControlToolkit follow following steps
1. Open Solution Explorer => Right Click on the Project Root
2. Click on Manage NuGet Packages...
Step 1:- Design Page
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.modalPopup {
border: 1px solid #2F4F4F;
background-color: #FFFFFF;
border-width: 3px;
border-style: solid;
border-color: black;
padding-top: 10px;
padding-left: 10px;
}
</style>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#btnSearch").click(function () {
var text = $("#txtSearch").val();
if (text == "") {
alert("Enter URL.");
$("#txtSearch").focus();
return false;
}
else {
$("#iframe1").attr("src", text);
return false;
}
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<asp:Button ID="Button1" runat="server" Text="Open iframe" OnClick="Button1_Click" />
<div id="Panel1" style="width: 90%; height: 90%;">
<table>
<tr>
<td>Enter URL :</td>
<td>
<asp:TextBox ID="txtSearch" runat="server" Width="500px"></asp:TextBox>
</td>
<td>
<asp:Button ID="btnSearch" runat="server" Text="Search" />
</td>
</tr>
</table>
<asp:ImageButton ID="ImageButton1" runat="server"
AlternateText="Close"
ImageUrl="Images/close.gif"
Style="position: absolute; right: -15px; top: 10px;"></asp:ImageButton>
<iframe id="iframe1" runat="server" src="http://dotnet-jigyasa.blogspot.com/"
scrolling="yes"
width="100%"
height="90%"
style="overflow: auto; background: #FFFFFF"></iframe>
</div>
<ajax:ModalPopupExtender ID="ModalPopupExtender1" runat="server"
TargetControlID="iframe1"
PopupControlID="Panel1"
CancelControlID="ImageButton1"
BehaviorID="ModalBehaviour"
BackgroundCssClass="modalPopup">
</ajax:ModalPopupExtender>
</div>
</form>
</body>
</html>
Step 2:- Code behind Page
protected void Button1_Click(object sender, EventArgs e)
{
ModalPopupExtender1.Show();
}
Step 3:- Output
No comments:
Post a Comment