将按钮文字更改为“”会移动以下元素

时间:2018-12-11 04:46:51

标签: c# html asp.net button webforms

实际发生的视频: https://www.youtube.com/watch?v=vCVHOSg8C-w&feature=youtu.be

因此...将按钮文本更改为“”会向下移动所有后续元素。

例如,我尝试将文本更改为“ 99”,没关系。仅当我尝试将文本更改为“”时才会出现问题。猜猜我可以为每个按钮使用绝对位置和左上角位置,并使所有元素都具有独立性,但是也许还有另一种解决方法?

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="sudoku3._Default" %>

  <asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
    <asp:UpdatePanel ID="updpanel1" runat="server">
      <ContentTemplate>
        <center><asp:Panel ID="panel2" runat="server" BackImageUrl="~/images/back.jpg" style="background-repeat:no-repeat; background-position:center; " Height="372" Width="372">
          <asp:Button ID="Button11" runat="server" Text="1" BackColor="Transparent" BorderStyle="None" Font-Size="15pt" Height="41.5px" Width="37px" OnClick="Button11_Click" BorderColor="LightGreen" BorderWidth="2px" />
          <asp:Button ID="Button12" runat="server" Text="2" BackColor="Transparent" BorderStyle="None" Font-Size="15pt" Height="41.5px" Width="37px" />
          <asp:Button ID="Button13" runat="server" Text="3" BackColor="Transparent" BorderStyle="None" Font-Size="15pt" Height="41.5px" Width="37px" />
          <asp:Button ID="Button14" runat="server" Text="4" BackColor="Transparent" BorderStyle="None" Font-Size="15pt" Height="41.5px" Width="37px" />
          <asp:Button ID="Button15" runat="server" Text="5" BackColor="Transparent" BorderStyle="None" Font-Size="15pt" Height="41.5px" Width="37px" />
          <asp:Button ID="Button16" runat="server" Text="6" BackColor="Transparent" BorderStyle="None" Font-Size="15pt" Height="41.5px" Width="37px" />
          <asp:Button ID="Button17" runat="server" Text="7" BackColor="Transparent" BorderStyle="None" Font-Size="15pt" Height="41.5px" Width="37px" />
          <asp:Button ID="Button18" runat="server" Text="8" BackColor="Transparent" BorderStyle="None" Font-Size="15pt" Height="41.5px" Width="37px" />
          <asp:Button ID="Button19" runat="server" Text="9" BackColor="Transparent" BorderStyle="None" Font-Size="15pt" Height="41.5px" Width="37px" />
            <asp:Button ID="Button21" runat="server" Text="1" BackColor="Transparent" BorderStyle="None" Font-Size="15pt" Height="41.5px" Width="37px" />
            <asp:Button ID="Button22" runat="server" Text="2" BackColor="Transparent" BorderStyle="None" Font-Size="15pt" Height="41.5px" Width="37px" />
            <asp:Button ID="Button23" runat="server" Text="3" BackColor="Transparent" BorderStyle="None" Font-Size="15pt" Height="41.5px" Width="37px" />
            <asp:Button ID="Button24" runat="server" Text="4" BackColor="Transparent" BorderStyle="None" Font-Size="15pt" Height="41.5px" Width="37px" />
            <asp:Button ID="Button25" runat="server" Text="5" BackColor="Transparent" BorderStyle="None" Font-Size="15pt" Height="41.5px" Width="37px" />
            <asp:Button ID="Button26" runat="server" Text="6" BackColor="Transparent" BorderStyle="None" Font-Size="15pt" Height="41.5px" Width="37px" />
            <asp:Button ID="Button27" runat="server" Text="7" BackColor="Transparent" BorderStyle="None" Font-Size="15pt" Height="41.5px" Width="37px" />
            <asp:Button ID="Button28" runat="server" Text="8" BackColor="Transparent" BorderStyle="None" Font-Size="15pt" Height="41.5px" Width="37px" />
            <asp:Button ID="Button29" runat="server" Text="9" BackColor="Transparent" BorderStyle="None" Font-Size="15pt" Height="41.5px" Width="37px" />
        </asp:Panel>
        </center>
      </ContentTemplate>
    </asp:UpdatePanel>
  </asp:Content>

        protected void Button1_Click(object sender, EventArgs e)
    {
        switch(LastButton)
        {
            case 11:
                Button11.Text = "";
                break;
        }
    }

    protected void Button2_Click(object sender, EventArgs e)
    {
        switch (LastButton)
        {
            case 11:
                Button11.Text = "1";
                break;
        }
    }

0 个答案:

没有答案