📄 imagelabeltest.aspx
字号:
<%@ Page Language="c#" %>
<%@ Register TagPrefix="uc1" TagName="SiteFooter" Src="../UserControls/SiteFooter.ascx" %>
<%@ Register TagPrefix="uc1" TagName="SiteHeader" Src="../UserControls/SiteHeader.ascx" %>
<%@ Register TagPrefix="mspsc" Namespace="MSPress.ServerComponents" Assembly="MSPress.ServerComponents" %>
<%@ Import Namespace="System.Drawing" %>
<script runat="server">
private void Page_Load(object sender, EventArgs e) {
imageLabel1.Text = textTextBox.Text;
imageLabel1.Font.Name = fontNameDropDown.SelectedItem.Text;
imageLabel1.Font.Size = new FontUnit(fontSizeTextBox.Text.Trim());
imageLabel1.Font.Bold = boldCheckBox.Checked;
imageLabel1.Font.Italic = italicCheckBox.Checked;
imageLabel1.Font.Underline = underLineCheckBox.Checked;
imageLabel1.Width = Unit.Pixel(Int32.Parse(widthTextBox.Text.Trim()));
imageLabel1.Height = Unit.Pixel(Int32.Parse(heightTextBox.Text.Trim()));
imageLabel1.ForeColor = Color.FromName(foreColorDropDown.SelectedItem.Text);
imageLabel1.BackColor = Color.FromName(backColorDropDown.SelectedItem.Text);
imageLabel1.HorizontalAlign = (HorizontalAlign)Int32.Parse(horizAlignDropDown.SelectedItem.Value);
imageLabel1.VerticalAlign = (VerticalAlign)Int32.Parse(vertAlignDropDown.SelectedItem.Value);
string s = imageLabel1.ImageUrl;
imageHyperLink.Text = s;
imageHyperLink.NavigateUrl = s;
}
</script>
<html>
<head>
<title>ImageLabelHandler Demo</title>
<link href="../Default.css" type="text/css" rel="stylesheet" />
</head>
<body>
<form id="ImageLabelTest" method="post" runat="server">
<p>
<uc1:siteheader id="SiteHeader1" runat="server" Heading="Chapter 19" SubHeading="ImageLabelHandler Sample"></uc1:siteheader>
</p>
<p>
This page uses the ImageLabel control and ImageLabelHandler to generate dynamic images
based on your selections below.
</p>
<p>
<table width="100%" border="0">
<tbody>
<tr>
<td nowrap="nowrap">Text: </td>
<td nowrap width="100%">
<asp:textbox id="textTextBox" runat="server" Width="250px">Sample Text</asp:textbox>
</td>
</tr>
<tr>
<td nowrap="nowrap">Font: </td>
<td nowrap="nowrap">
<asp:dropdownlist id="fontNameDropDown" runat="server" Width="100px">
<asp:ListItem Value="Comic Sans MS">Comic Sans MS</asp:ListItem>
<asp:ListItem Value="Tahoma">Tahoma</asp:ListItem>
<asp:ListItem Value="Times New Roman">Times New Roman</asp:ListItem>
<asp:ListItem Value="Trebuchet MS">Trebuchet MS</asp:ListItem>
<asp:ListItem Value="Verdana" Selected="True">Verdana</asp:ListItem>
<asp:ListItem Value="Wingdings">Wingdings</asp:ListItem>
</asp:dropdownlist>
<asp:textbox id="fontSizeTextBox" runat="server" Columns="3" MaxLength="2">10</asp:textbox>
<asp:checkbox id="boldCheckBox" runat="server" Checked="True" Text="Bold"></asp:checkbox>
<asp:checkbox id="italicCheckBox" runat="server" Text="Italic"></asp:checkbox>
<asp:checkbox id="underLineCheckBox" runat="server" Text="Underline"></asp:checkbox>
</td>
</tr>
<tr>
<td nowrap="nowrap">Text Color: </td>
<td nowrap="nowrap">
<asp:dropdownlist id="foreColorDropDown" runat="server" Width="100px">
<asp:ListItem Value="Black">Black</asp:ListItem>
<asp:ListItem Value="White">White</asp:ListItem>
<asp:ListItem Value="Red" Selected="True">Red</asp:ListItem>
<asp:ListItem Value="Green">Green</asp:ListItem>
<asp:ListItem Value="Blue">Blue</asp:ListItem>
</asp:dropdownlist>
</td>
</tr>
<tr>
<td nowrap="nowrap">Background Color: </td>
<td nowrap="nowrap">
<asp:dropdownlist id="backColorDropDown" runat="server" Width="100px">
<asp:ListItem Value="White" Selected="True">White</asp:ListItem>
<asp:ListItem Value="Black">Black</asp:ListItem>
</asp:dropdownlist>
</td>
</tr>
<tr>
<td nowrap="nowrap">Horizontal Alignment: </td>
<td nowrap="nowrap">
<asp:dropdownlist id="horizAlignDropDown" runat="server" Width="100px">
<asp:ListItem Value="1">Left</asp:ListItem>
<asp:ListItem Value="2">Center</asp:ListItem>
<asp:ListItem Value="3">Right</asp:ListItem>
</asp:dropdownlist>
</td>
</tr>
<tr>
<td nowrap="nowrap">Vertical Alignment: </td>
<td nowrap="nowrap">
<asp:dropdownlist id="vertAlignDropDown" runat="server" Width="100px">
<asp:ListItem Value="1">Top</asp:ListItem>
<asp:ListItem Value="2">Middle</asp:ListItem>
<asp:ListItem Value="3">Bottom</asp:ListItem>
</asp:dropdownlist>
</td>
</tr>
<tr>
<td nowrap="nowrap">Width: </td>
<td nowrap="nowrap">
<asp:textbox id="widthTextBox" runat="server" Columns="4" MaxLength="4">200</asp:textbox>
</td>
</tr>
<tr>
<td nowrap="nowrap">Height: </td>
<td nowrap="nowrap">
<asp:textbox id="heightTextBox" runat="server" Columns="4" MaxLength="4">50</asp:textbox>
</td>
</tr>
<tr>
<td nowrap colspan="2">
<mspsc:ImageLabel id="imageLabel1" runat="server" EnableViewState="False" BorderStyle="Solid" BorderWidth="1px" BorderColor="LightSkyBlue" ImageLabelHandlerUrl="ImageLabel.ashx"></mspsc:ImageLabel>
</td>
</tr>
<tr>
<td nowrap colspan="2">
<asp:HyperLink id="imageHyperLink" runat="server" Font-Size="8pt"></asp:HyperLink>
</td>
</tr>
</tbody>
</table>
</p>
<p>
<asp:LinkButton id="generateButton" runat="server">Generate!</asp:LinkButton>
</p>
<p>
<uc1:SiteFooter id="SiteFooter1" runat="server"></uc1:SiteFooter>
</p>
</form>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -