Dynamically add Seo information, and do not repeat and overlay static pages. You can use it as a record. You can use it as needed.
1 /// <summary>
2 // dynamically set Seo Information
3 /// </Summary>
4 /// <Param name = "title"> title </param>
5 // <Param name = "key"> keyword </param>
6 /// <Param name = "des"> description </param>
7 public void setmeta (String title, string key, string des)
8 {
9 If (! String. isnullorempty (title ))
10 {
11 page. Title + = title;
12}
13 if (! String. isnullorempty (key ))
14 {
15 Boolean edited = false;
16 For (INT a_ I = 0; a_ I <= page. header. Controls. Count-1; a_ I ++)
17 {
18 if (page. header. controls [a_ I]. GetType () = typeof (htmlmeta ))
19 {
20 htmlmeta setmeta = (htmlmeta) page. header. controls [a_ I];
21
22 if (setmeta. Name. tolower () = "keywords ")
23 {
24 setmeta. content = setmeta. content. tostring () + "" + key;
25 edited = true;
26 break;
27}
28}
29}
30 if (! Edited)
31 {
32 htmlmeta newkeywords = new htmlmeta ();
33 newkeywords. Name = "keywords ";
34 newkeywords. content = key;
35 page. header. Controls. Add (newkeywords );
36}
37}
38 If (! String. isnullorempty (DES ))
39 {
40 Boolean edited = false;
41 for (INT a_ I = 0; a_ I <= page. header. Controls. Count-1; a_ I ++)
42 {
43 If (page. header. controls [a_ I]. GetType () = typeof (htmlmeta ))
44 {
45 htmlmeta setmeta = (htmlmeta) page. header. controls [a_ I];
46
47 If (setmeta. Name. tolower () = "Description ")
48 {
49 setmeta. content = setmeta. content. tostring () + "" + des;
50 edited = true;
51 break;
52}
53}
54}
55 if (! Edited)
56 {
57 htmlmeta newkeywords = new htmlmeta ();
58 newkeywords. Name = "Description ";
59 newkeywords. content = des;
60 page. header. Controls. Add (newkeywords );
61}
62}
63}