温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:MyWebPages51aspx汉化最终版
当前文件:
MyWebPagesStarterKit/App_Code/Controls/ResizedImage.cs,打开代码结构图
MyWebPagesStarterKit/App_Code/Controls/ResizedImage.cs,打开代码结构图1//=============================================================================================== 2
// 3
// (c) Copyright Microsoft Corporation. 4
// This source is subject to the Microsoft Permissive License. 5
// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx. 6
// All other rights reserved. 7
// 8
//=============================================================================================== 9
10
using System; 11
using System.Data; 12
using System.Configuration; 13
using System.Web; 14
using System.Web.Security; 15
using System.Web.UI; 16
using System.Web.UI.WebControls; 17
using System.Web.UI.WebControls.WebParts; 18
using System.Web.UI.HtmlControls; 19
using System.ComponentModel; 20
21
namespace MyWebPagesStarterKit.Controls 22
{ 23
[ToolboxData("<{0}:ResizedImage runat=server></{0}:ResizedImage>")] 24
public class ResizedImage : Image 25
{ 26
public string SectionId 27
{ 28
get { return (ViewState["SectionId"] == null) ? string.Empty : (string)ViewState["SectionId"]; } 29
set { ViewState["SectionId"] = value; } 30
} 31
32
public string PageId 33
{ 34
get { return (ViewState["PageId"] == null) ? string.Empty : (string)ViewState["PageId"]; } 35
set { ViewState["PageId"] = value; } 36
} 37
38
public int MaxWidth 39
{ 40
get { return (ViewState["MaxWidth"] == null) ? 50 : (int)ViewState["MaxWidth"]; } 41
set { ViewState["MaxWidth"] = value; } 42
} 43
44
public int MaxHeight 45
{ 46
get { return (ViewState["MaxHeight"] == null) ? 50 : (int)ViewState["MaxHeight"]; } 47
set { ViewState["MaxHeight"] = value; } 48
} 49
50
protected override void OnPreRender(EventArgs e) 51
{ 52
base.OnPreRender(e); 53
GenerateEmptyAlternateText = true; 54
55
if (SectionId != string.Empty) 56
{ 57
ImageUrl = string.Format( 58
"~/ImageHandler.ashx?pg={0}§ion={1}&image={2}&height={3}&width={4}", 59
PageId, 60
SectionId, 61
HttpUtility.UrlEncode(ImageUrl), 62
MaxHeight, 63
MaxWidth 64
); 65
} 66
else 67
{ 68
ImageUrl = string.Format( 69
"~/ImageHandler.ashx?image={0}&height={1}&width={2}", 70
HttpUtility.UrlEncode(ImageUrl), 71
MaxHeight, 72
MaxWidth 73
); 74
} 75
76
} 77
} 78
}




[ToolboxData(
}
}