当前位置: 代码迷 >> ASP.NET >> 自定义控件有关问题
  详细解决方案

自定义控件有关问题

热度:4504   发布时间:2013-02-25 00:00:00.0
自定义控件问题?
在aspx页面中正常,于是我把代码分离到ascx里。
代码如下:
UserLogin.ascx
C# code
 
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="UserLogin.ascx.cs" Inherits="UserLogin" %>
<form id="form1" name="form1" runat="server" method="post" >
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
  <td width="177"> <img src="img/yhdl.jpg" width="177" height="47" /> </td>
</tr>
<tr>
  <td width="177" align="right" background="img/yhdlbg.jpg" style="height: 25px"> <table width="90%" height="25" border="0" cellpadding="0" cellspacing="0" class="zt">
      <tr>
        <td align="center" style="height: 37px">用户名: </td>
        <td style="height: 37px; text-align: left"> <label>
            &nbsp; <asp:TextBox ID="UserName" runat="server" Height="13px" Width="78px"  > </asp:TextBox>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="UserName"
                ErrorMessage="*"> </asp:RequiredFieldValidator> </label> </td>
      </tr>
  </table> </td>
</tr>
<tr>
  <td width="177" height="25" align="right" background="img/yhdlbg.jpg"> <table width="90%" height="25" border="0" cellpadding="0" cellspacing="0" class="zt">
      <tr>
        <td align="center" style="height: 25px">密&nbsp; 码: </td>
        <td style="height: 25px; text-align: left"> <label>
            &nbsp; <asp:TextBox ID="Password" runat="server" Height="13px" TextMode="Password"
                Width="78px"> </asp:TextBox>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="Password"
                ErrorMessage="*"> </asp:RequiredFieldValidator> </label> </td>
      </tr>
  </table> </td>
</tr>
<tr>
  <td width="177" height="35" align="center" background="img/yhdlbg.jpg"> <table width="85%" border="0" cellspacing="0" cellpadding="0">
      <tr>
          <td align="center" colspan="2" style="height: 20px">
              <label>
            &nbsp; <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/img/dl.jpg" OnClick="ImageButton1_Click" /> </label> <label>&nbsp; </label> </td>
      </tr>
  </table> </td>
</tr>
  相关解决方案