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.


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>


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

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

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 = ""

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


**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: