ascx的代码是:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="MainTitle.ascx.cs" Inherits="Controls_MainTitle" %>
<table cellpadding="0" cellspacing="0" style="width: 1000px; background-image: url(pic/banner.jpg);">
<tr>
<td style="vertical-align: top; background-repeat: repeat-x;
height: 160px " colspan="2">
<br />
<asp:Label ID="lblTitle" runat="server" Font-Bold="True" Font-Italic="False" Font-Names="幼圆"
Font-Size="25pt" Font-Strikeout="False" Font-Underline="False" Height="40px"
Text="管理员后台" Width="210px" ForeColor="DarkGreen" style="z-index: 100; left: 355px; position: absolute; top: 89px"></asp:Label></td>
</tr>
<tr >
<td style="background-image: url(IMAGES/line.jpg); background-repeat: repeat-x; width: 30%;
height: 31px;">
</td>
<td style="background-image: url(IMAGES/line.jpg); background-repeat: repeat-x; text-align: center;
height: 31px;">
<table style="width: 500px">
<tr>
<td align="center" valign="middle" style="width: 122px">
<asp:Button ID="Button1" runat="server" Text="审核注册" onclick="Button1_Click" />
</td>
<td align="center" valign="middle">
<asp:Button ID="Button2" runat="server" Text="审核交款" onclick="Button2_Click" />
</td>
<td align="center" valign="middle">
<asp:Button ID="Button3" runat="server" Text="搜索用户" onclick="Button3_Click" />
</td>
<td align="center" valign="middle">
<asp:Button ID="Button4" runat="server" Text="安全退出" onclick="Button4_Click" />
</td>
</tr>
</table>
</td>
</tr>
</table>
代码有没有错?我运用时直接把ascx拖到ascp中的,产生的代码是:<uc1:MainTitle ID="MainTitle1" runat="server" />
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="MainTitle.ascx.cs" Inherits="Controls_MainTitle" %>
<table cellpadding="0" cellspacing="0" style="width: 1000px; background-image: url(pic/banner.jpg);">
<tr>
<td style="vertical-align: top; background-repeat: repeat-x;
height: 160px " colspan="2">
<br />
<asp:Label ID="lblTitle" runat="server" Font-Bold="True" Font-Italic="False" Font-Names="幼圆"
Font-Size="25pt" Font-Strikeout="False" Font-Underline="False" Height="40px"
Text="管理员后台" Width="210px" ForeColor="DarkGreen" style="z-index: 100; left: 355px; position: absolute; top: 89px"></asp:Label></td>
</tr>
<tr >
<td style="background-image: url(IMAGES/line.jpg); background-repeat: repeat-x; width: 30%;
height: 31px;">
</td>
<td style="background-image: url(IMAGES/line.jpg); background-repeat: repeat-x; text-align: center;
height: 31px;">
<table style="width: 500px">
<tr>
<td align="center" valign="middle" style="width: 122px">
<asp:Button ID="Button1" runat="server" Text="审核注册" onclick="Button1_Click" />
</td>
<td align="center" valign="middle">
<asp:Button ID="Button2" runat="server" Text="审核交款" onclick="Button2_Click" />
</td>
<td align="center" valign="middle">
<asp:Button ID="Button3" runat="server" Text="搜索用户" onclick="Button3_Click" />
</td>
<td align="center" valign="middle">
<asp:Button ID="Button4" runat="server" Text="安全退出" onclick="Button4_Click" />
</td>
</tr>
</table>
</td>
</tr>
</table>
代码有没有错?我运用时直接把ascx拖到ascp中的,产生的代码是:<uc1:MainTitle ID="MainTitle1" runat="server" />
<td style="background-image: url(IMAGES/line.jpg); background-repeat: repeat-x; text-align: center;
height: 31px;">可以修改为 <td runat="server" ID="myTd1">然后在page_load中设置myTD1.Attributes["style"]=....
根据你的网站安装的网站目录或者网站虚拟目录的不同,网络应用程序也许安装在domain,也许在abc,也许在def,因此只有asp.net运行时才知道如何计算,你在设计网站应用程序时根本不需要想当然地以为它是放在根域下还是某一级的虚拟目录下。
http://domain/abc/IMAGES/.....
http://domain/abc/def/IMAGES/.....都有可能。再加上你的ascx不一定嵌入上述asp.net应用程序的某一个子目录下的某一个aspx中,比如同时在以下这两个aspx都有嵌入:
http://domain/abc/IMAGES/xxx.aspx
http://domain/abc/IMAGES/user1/xxx.aspx可见控件不可能想当然地在设计时就设计好图片路径,必须动态计算。
http://domain/abc/user1/xxx.aspx这里假设IMAGES是你asp.net网站应用程序下的一个一级子目录,但是由于它实际在部署时是配置到网站http://domain下的一级虚拟目录abc下了,所以你的网站应用程序的所有目录其实都隶属在这个虚拟目录下而不是网站根目录下了。