显示:块不起作用

本文关键字:不起作用 显示 | 更新日期: 2023-09-27 18:34:10

我很累,因为这个问题持续了一整天。下面的代码似乎很长,但不难理解我在代码中做了什么。 希望你能给我一个解决方案。

我有一个面板ID="ASPxPanel2",将 stype 设置为 display:none .

单击按钮New -->后,将显示面板。

<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<table>
<tr>
<td>
<dx:ASPxPanel ID="ASPxPanel2" runat="server" Width="700px" Height="150px"  RenderMode="Table"  CssClass="display_none">//set to display:none here
<PanelCollection>
<dx:PanelContent ID="PanelContent1" runat="server" SupportsDisabledAttribute="True">
<table>
<tr>
<td colspan=4>
    <asp:Label ID="LabelError" runat="server" ForeColor="red" Text="">
     </asp:Label>
</td
</tr>
<tr>
<td>Đối tượng</td>
<td>
    <dx:ASPxComboBox ID="MA_DOI_TUONG" runat="server" ClientIDMode="AutoID" 
        ValueType="System.String">
    </dx:ASPxComboBox>
</td>
<td>Loại</td>
<td >
       <dx:ASPxComboBox ID="MA_LOAI" runat="server" ClientIDMode="AutoID" 
        ValueType="System.String">
    </dx:ASPxComboBox> 
</td>
<td class="style6">
&nbsp;</td>
<td rowspan=5>
    MoreFileUpload
                    <div style="display: "";" id="div0">
                    <dx:ASPxTextBox ID="TFileUpload0" runat="server" ClientIDMode="AutoID" 
                            Width="180px" Height="16px">
                    </dx:ASPxTextBox>
                    <asp:FileUpload ID="FileUpload0" runat="server" accept="png|jpg" Width="180px" size=32 />
                    </div>
                    <div style="display: none;" id="div1">
                    <dx:ASPxTextBox ID="TFileUpload1" runat="server" ClientIDMode="AutoID" 
                            Width="180px" Height="16px">
                    </dx:ASPxTextBox>                    
                    <asp:FileUpload ID="FileUpload1" runat="server" accept="png|jpg" Width="180px" size=32 />
                    </div>
                    <div style="display: none;" id="div2">
                    <dx:ASPxTextBox ID="TFileUpload2" runat="server" ClientIDMode="AutoID" 
                            Width="180px" Height="16px">
                    </dx:ASPxTextBox>
                    <asp:FileUpload ID="FileUpload2" runat="server" accept="png|jpg" Width="180px" size=32 />
                    </div>   
                     <div style="display: none;" id="div3">
                    <dx:ASPxTextBox ID="TFileUpload3" runat="server" ClientIDMode="AutoID" 
                            Width="180px" Height="16px">
                    </dx:ASPxTextBox>                    
                    <asp:FileUpload ID="FileUpload3" runat="server" accept="png|jpg" Width="180px" size=32 />
                    </div>
                    <div style="display: none;" id="div4">
                    <dx:ASPxTextBox ID="TFileUpload4" runat="server" ClientIDMode="AutoID" 
                            Width="180px" Height="16px">
                    </dx:ASPxTextBox>
                    <asp:FileUpload ID="FileUpload4" runat="server" accept="png|jpg" Width="180px" size=32 />
                    </div>
                    <div style="display: none;" id="div5">
                    <dx:ASPxTextBox ID="TFileUpload5" runat="server" ClientIDMode="AutoID" 
                            Width="180px" Height="16px">
                    </dx:ASPxTextBox>                    
                    <asp:FileUpload ID="FileUpload5" runat="server" accept="png|jpg" Width="180px" size=32 />
                    </div>
                    <div style="display: none;" id="div6">
                    <dx:ASPxTextBox ID="TFileUpload6" runat="server" ClientIDMode="AutoID" 
                            Width="180px" Height="16px">
                    </dx:ASPxTextBox>
                    <asp:FileUpload ID="FileUpload6" runat="server" accept="png|jpg" Width="180px" size=32 />
                    </div>
                    <div style="display: none;" id="div7">
                    <dx:ASPxTextBox ID="TFileUpload7" runat="server" ClientIDMode="AutoID" 
                            Width="180px" Height="16px">
                    </dx:ASPxTextBox>                    
                    <asp:FileUpload ID="FileUpload7" runat="server" accept="png|jpg" Width="180px" size=32 />
                    </div>
                    <div style="display: none;" id="div8">
                    <dx:ASPxTextBox ID="TFileUpload8" runat="server" ClientIDMode="AutoID" 
                            Width="180px" Height="16px">
                    </dx:ASPxTextBox>
                    <asp:FileUpload ID="FileUpload8" runat="server" accept="png|jpg" Width="180px" size=32 />
                    </div>
                    <div style="display: none;" id="div9">
                    <dx:ASPxTextBox ID="TFileUpload9" runat="server" ClientIDMode="AutoID" 
                            Width="180px" Height="16px">
                    </dx:ASPxTextBox>                    
                    <asp:FileUpload ID="FileUpload9" runat="server" accept="png|jpg" Width="180px" size=32 />
                    </div>
                    <div style="display: none;" id="div10">
                    <dx:ASPxTextBox ID="TFileUpload10" runat="server" ClientIDMode="AutoID" 
                            Width="180px" Height="16px">
                    </dx:ASPxTextBox>
                    <asp:FileUpload ID="FileUpload10" runat="server" accept="png|jpg" Width="180px" size=32 />
                    </div>
                    <div style="display: none;" id="div11">
                    <dx:ASPxTextBox ID="TFileUpload11" runat="server" ClientIDMode="AutoID" 
                            Width="180px" Height="16px">
                    </dx:ASPxTextBox>                    
                    <asp:FileUpload ID="FileUpload11" runat="server" accept="png|jpg" Width="180px" size=32 />
                    </div>
                    <div style="display: none;" id="div12">
                    <dx:ASPxTextBox ID="TFileUpload12" runat="server" ClientIDMode="AutoID" 
                            Width="180px" Height="16px">
                    </dx:ASPxTextBox>
                    <asp:FileUpload ID="FileUpload12" runat="server" accept="png|jpg" Width="180px" size=32 />
                    </div>
                    <div style="display: none;" id="div13">
                    <dx:ASPxTextBox ID="TFileUpload13" runat="server" ClientIDMode="AutoID" 
                            Width="180px" Height="16px">
                    </dx:ASPxTextBox>                    
                    <asp:FileUpload ID="FileUpload13" runat="server" accept="png|jpg" Width="180px" size=32 />
                    </div>
                    <div style="display: none;" id="div14">
                    <dx:ASPxTextBox ID="TFileUpload14" runat="server" ClientIDMode="AutoID" 
                            Width="180px" Height="16px">
                    </dx:ASPxTextBox>
                    <asp:FileUpload ID="FileUpload14" runat="server" accept="png|jpg" Width="180px" size=32 />
                    </div>
                    <div style="display: none;" id="div15">
                    <dx:ASPxTextBox ID="TFileUpload15" runat="server" ClientIDMode="AutoID" 
                            Width="180px" Height="16px">
                    </dx:ASPxTextBox>                    
                    <asp:FileUpload ID="FileUpload15" runat="server" accept="png|jpg" Width="180px" size=32 />
                    </div>
                    <div style="display: none;" id="div16">
                    <dx:ASPxTextBox ID="TFileUpload16" runat="server" ClientIDMode="AutoID" 
                            Width="180px" Height="16px">
                    </dx:ASPxTextBox>
                    <asp:FileUpload ID="FileUpload16" runat="server" accept="png|jpg" Width="180px" size=32 />
                    </div>
                    <div style="display: none;" id="div17">
                    <dx:ASPxTextBox ID="TFileUpload17" runat="server" ClientIDMode="AutoID" 
                            Width="180px" Height="16px">
                    </dx:ASPxTextBox>                    
                    <asp:FileUpload ID="FileUpload17" runat="server" accept="png|jpg" Width="180px" size=32 />
                    </div>
                    <div style="display: none;" id="div18">
                    <dx:ASPxTextBox ID="TFileUpload18" runat="server" ClientIDMode="AutoID" 
                            Width="180px" Height="16px">
                    </dx:ASPxTextBox>
                    <asp:FileUpload ID="FileUpload18" runat="server" accept="png|jpg" Width="180px" size=32 />
                    </div>
                    <div style="display: none;" id="div19">
                    <dx:ASPxTextBox ID="TFileUpload19" runat="server" ClientIDMode="AutoID" 
                            Width="180px" Height="16px">
                    </dx:ASPxTextBox>
                    <asp:FileUpload ID="FileUpload19" runat="server" accept="png|jpg" Width="180px" size=27 />
                    </div>
                    <div style="text-align: left; width: 263px;" id="divShow">
                        <a id="linkMore" href="javascript:void(0)" onclick="javascript:ShowHideFileUpload(this.id)">
                            + Add More ...</a></div>
                    <br /><br />
</td>
</tr>
<tr>
<td>Title</td>
<td class="style5" colspan=3>
    <dx:ASPxTextBox ID="TITLE" runat="server" ClientIDMode="AutoID" 
        Width="300px" Height="16px" >
    </dx:ASPxTextBox>
</td>
</tr>
<tr><td>Content</td>
<td class="style2" colspan=3>
       <FTB:FreeTextBox id="ftCONTENT" runat="server"
       ToolbarLayout="ParagraphMenu,FontFacesMenu,FontSizesMenu,FontForeColorsMenu,FontForeColorPicker,FontBackColorsMenu,FontBackColorPicker|Bold,Italic,Underline,JustifyLeft,JustifyRight,JustifyCenter,JustifyFull;BulletedList,NumberedList,
       Cut,Copy,Paste,Delete;Undo,Redo,InsertTable,EditTable;InsertTableRowAfter,InsertTableRowBefore,DeleteTableRow;InsertTableColumnAfter,InsertTableColumnBefore,DeleteTableColumn" 
            EditorBorderColorDark="DarkGray" EditorBorderColorLight="DarkGray" 
            Width="100%" GutterBorderColorDark="Gray" GutterBorderColorLight="White" 
            ToolbarStyleConfiguration="Office2000" AutoGenerateToolbarsFromString="True" JavaScriptLocation="InternalResource" />
</td>
</tr>
<tr>
<td>FileAttach</td>
<td colspan=3>
        <asp:FileUpload ID="PATH" runat="server" 
            size=40 Width="300px"/></td></tr>
<tr align=center>
<td colspan=5 align=center>
        <dx:ASPxButton ID="ASPxButton1" runat="server" ClientIDMode="AutoID" 
            style="text-align: center" Text="Thêm" HorizontalAlign="Center" 
            OnClick="btnInsert_Click">
        </dx:ASPxButton>
</td>
</tr>
</table>
</dx:PanelContent>
</PanelCollection>
</dx:ASPxPanel> 
   </td></tr>
</dx:ASPxPanel>
</td>
</tr>
</table>  
</asp:Panel>  //end ASPXPanel2 
<table>
       <tr>
      td><dx:ASPxPanel ID="ASPxPanel1" runat="server" Width="200px" RenderMode="Table">
    </dx:ASPxPanel>
   </td>
           <td>
                <asp:Button ID="btnNew" runat="server" Text="NEW" OnClick="btnNew_Click" />
            </td>
        </tr>
    </table> 

在后面的代码中:

 protected void btnNew_Click(object sender, EventArgs e)
    {
        ASPxPanel2.Attributes.Add("Sytle", "display:block");
//do something more
    }

我在触发btnNew_Click时添加了ASPxPanel2.Attributes.Add("Sytle", "display:block");,但 ASPxPanel2 未显示。

display:block不起作用吗??帮助!!!

更新:

我发现了我的错误,错字:"风格"而不是"Sytle"

但它有一个新的问题。

我的网页上仍然有ASPxPanel1。当我将ASPxPanel2显示:块设置为默认值时,Panel1将显示在Panel2下方。但是当我设置 Panel2 display:none 然后在代码后面再次设置它display:block时--->Panel2显示器盖Panel1

帮助!!!

我已经更新了上面的代码。请看一看!

显示:块不起作用

拼写错误

ASPxPanel2.Attributes.Add("Sytle", "display:block");

应改为

ASPxPanel2.Attributes.Add("Style", "display:block");