Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
Tags
- It
- XML
- cookie
- 제네릭
- IT 관련
- angularJS
- LINQ
- delegate
- 디자인패턴
- di
- Generic
- jQuery
- JavaScript
- MSSQL
- Excel
- 클래스
- asp.net mvc
- ASP.NET
- 메소드
- mvc
- SQL
- 구글
- ADO.NET
- csv
- 동적dom
- IT관련
- iframe
- c#
- Today
- 438
- Total
- 1,440,157
심재운 블로그
asp.net webform 의 child page 에서 master page 에 접근하여 metadata tag 값 추가하는 방법. 본문
닷넷관련/ASP.NET WEBFORM
asp.net webform 의 child page 에서 master page 에 접근하여 metadata tag 값 추가하는 방법.
재우니 2019. 9. 5. 01:01C# Adding MetaData to Master page from Child page dynamically
asp.net webform 의 child page 에서 master page 에 접근하여 metadata tag 값 추가하는 방법.
Masterpage.master.cs
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class MasterPage : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected override void OnPreRender(EventArgs e)
{
if (Description != null)
{
HtmlMeta metaD = new HtmlMeta();
metaD.Name = "description";
metaD.Content = Description;
this.Page.Header.Controls.Add(metaD);
}
if (Keywords != null)
{
HtmlMeta metaK = new HtmlMeta();
metaK.Name = "description";
metaK.Content = Keywords;
this.Page.Header.Controls.Add(metaK);
}
base.OnPreRender(e);
}
public string Description
{
get
{
if (ViewState["MetaDescription"] != null)
return (string)ViewState["MetaDescription"];
else
return null;
}
set
{
ViewState["MetaDescription"] = value;
}
}
public string Keywords
{
get
{
if (ViewState["MetaKeywords"] != null)
return (string)ViewState["MetaKeywords"];
else
return null;
}
set
{
ViewState["MetaKeywords"] = value;
}
}
}
child page
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
(Master as MasterPage).Keywords = "sarin, mobi";
(Master as MasterPage).Description = "Sarin Information Technology Expert";
}
}
http://www.sarin.mobi/2008/10/c-adding-metadata-to-master-page-from-child-page-dynamically/
'닷넷관련 > ASP.NET WEBFORM' 카테고리의 다른 글
asp.net webform 의 child page 에서 master page 에 접근하여 metadata tag 값 추가하는 방법. (0) | 2019.09.05 |
---|---|
asp.net webform 의 HTTP Headers 브라우저 캐시 차단하는 방법 (0) | 2017.09.11 |
asp.net 으로 google URL Shortener 짧은 주소 url 구현하기 (0) | 2017.06.05 |
machinekey 생성하는 validationkey 와 decryptionkey 값 생성하는 방법 (0) | 2016.10.26 |
Microsoft.AspNet.FriendlyUrls 의 webform 에서 routing 사용법 (0) | 2015.12.21 |
asp.net webform 에서 잘못된 페이지 호출시 다른 페이지로 이동하기 (0) | 2015.12.17 |
0 Comments