Ahsan's Experience

sharing experiences in .net ………

Use Master page tag in Content page of asp.net

How to use the <body> onclick from content page in asp.net?

Master page is introducing from asp.net 2.0, this is the main layout page for whole application content page just inherit it.

So that,we get the <body> tag only in Master page,in content page there is no body tag. But I need to use this body tag from content page.

After search it I found a solution in asp.net forum. Original link: http://forums.asp.net/t/1062445.aspx

Sample:

<%@ Page Language=”C#” MasterPageFile=”~/MasterPage.master” AutoEventWireup=”true” CodeFile=”Default.aspx.cs” Inherits=”Default” Title=”Test Page” %>

<asp:Content ID=”Content1″ ContentPlaceHolderID=”ContentPlaceHolder1″ Runat=”Server”>
<script type=”text/javascript”>

function ClearBox()
{
var divBoxID=document.getElementById(‘BoxDiv’);
divBoxID.style.display=’none’;
}

document.body.onclick= ClearBox;

</script>

<input id=”Button1″ type=”button” value=”button” />

</asp:Content>

For more info pls visit:
http://msdn.microsoft.com/en-us/library/7a9d6h4f.aspx
http://forums.asp.net/t/1225951.aspx

April 20, 2010 - Posted by | asp.net, C#, Html, Master Page | ,

No comments yet.

Leave a comment