Saturday, June 21, 2008

Add meta tags to master page from content page Asp.Net

This post describes adding a meta tag in an dynamic page with dynamically generated content. This code can be used if you want to add meta tag to a page which is using Master pages.

Step1

Put one content place holder in your master page in HEAD section, like::

<head id="Head1" runat="server">
    <asp:ContentPlaceHolder runat="server" id="ContentHeaders"></asp:ContentPlaceHolder>
</head>


Step2

Now in the content (child) page, put this code:

<asp:Content ID="Content2" ContentPlaceHolderID="ContentHeaders" runat="server">
    <TITLE><%=pageTitle%></TITLE>
    <META name="keywords" content="<%=varKeywords%>">
    <META name="description" content="<%=varDescription%>">
</asp:Content>


Step3
In content page's vb or cs file code:

Declare variables as below in the global declaration section (not in page load)


Protected pageTitle As String = ""
Protected varKeywords As String = ""
Protected varDescription As String = ""


Step4
Fill values in page_load event:

pageTitle = "Your Meta Tag "
varKeywords = "Your Meta Tag "
varDescription = "Your Meta Tag "

Disable the right click on a web page

Some website has right-click disabled so that user cant copy paste using mouse, or cant save images contained into webpage.


Copy paste this code


<body oncontextmenu=”return false;”>

Html page content here

</body>


**End of article**

Wednesday, June 18, 2008

Rotate a Label Text

Display Vertically rotated text on a server side label ASP.NET or in a HTML control

<asp:Label id="lblTotate" style="writing-mode:tb-rl" runat="server">your text here</asp:Label>

For more reference:

http://www.w3.org/TR/2001/WD-css3-text-20010517/

http://msdn.microsoft.com/en-us/library/ms531187.aspx