Tuesday, February 9, 2010

Use Master page <body> 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

6 comments:

Anonymous said...

hello,simple but helpful.

Unknown said...

welcome,thanks for your feedback, I always try to share important info which is helpful for all.

Anonymous said...

ok fine next http://hasanprogram.blogspot.com/

Anonymous said...

Good point, though sometimes it's hard to arrive to definite conclusions

Anonymous said...

good start

Anonymous said...

thanks for the interesting information

Method 'StartWorkflowOnListItem' in type 'Microsoft.SharePoint.WorkflowServices.FabricWorkflowInstanceProvider'

Exception: Method 'StartWorkflowOnListItem' in type 'Microsoft.SharePoint.WorkflowServices.FabricWorkflowInstanceProvider'...