Updating Keywords Masterpage from Content Page

Saturday, August 01, 2015 Unknown 0 Comments

If you want to update a control from the masterpage in ASP.net 2.0, you will need to follow three simple steps per control.

Assign the Control as a server control on the aspx page.

meta name="keywords" content="" id="MyMetaTag" runat="server"

Create a Property in masterpage to access from content pages

Public Property MetaData() As String
Get
Return MyMetaTag.Content
End Get
Set(ByVal value As String)
MyMetaTag.Content = value
End Set
End Property

Update Control from content page.

Dim myMaster As MasterPage = CType(Me.Master, MasterPage)
myMaster.MetaData = something.tostring

What Happens is the Content attribute of the Control (mymetatag) on the masterpage gets updated with something.tostring

Create property's to control any attributes from master page.
ie. visible = true of false
etc. etc.

0 comments :

Powered by Blogger.