WizLiz WizLiz - 18 days ago 5
ASP.NET (C#) Question

asp:FileUpload won't center within a fieldset

I'm trying to center a bunch of control within a fieldset and 2 of them are

<asp:FileUpload />
.One is behaving as intended but not the other :

enter image description here

I've created my fieldset within a
<div id="container">
and inside the fieldset you have a
<div class="content">
which contains the Labels, FileUpload etc.

The aspx file is as follow :

<div id="container">
<fieldset>
<legend style="color:#CC0000; font-size:medium; font-weight:bold">Nouvelle demande de tarif imagé</legend>
<br />
<div class="content">
<asp:Label ID="Label2" runat="server" Text="Nom du catalogue : "
Font-Bold="True"></asp:Label>
<asp:TextBox ID="TB_name" runat="server"></asp:TextBox>
<asp:CustomValidator ID="CustomValidator2" runat="server"
ErrorMessage="CustomValidator" ControlToValidate="TB_name" ForeColor="#CC0000"
onservervalidate="CustomValidator2_ServerValidate" ValidateEmptyText="True"></asp:CustomValidator>
<br />
<br />
<asp:Label ID="Label3" runat="server"
Text="Veuillez sélectionner un fichier CSV :" Font-Bold="True"></asp:Label><br />
<br />
<asp:FileUpload ID="csvUpload" runat="server" />
<asp:CustomValidator ID="CustomValidator1" runat="server"
ErrorMessage="CustomValidator" ControlToValidate="csvUpload"
Display="Dynamic" ForeColor="#CC0000"
onservervalidate="CustomValidator1_ServerValidate"
ValidateEmptyText="True"></asp:CustomValidator>
<br />
<br />
<br />
<asp:Label ID="Label1" runat="server"
Text="Veuillez sélectionner un logo (facultatif) :" Font-Bold="True"></asp:Label><br />
<br />
<asp:FileUpload ID="pictureUpload" runat="server" />
<asp:CustomValidator ID="CustomValidator3" runat="server"
ErrorMessage="CustomValidator" ControlToValidate="pictureUpload"
ForeColor="#CC0000" onservervalidate="CustomValidator3_ServerValidate"
ValidateEmptyText="True"></asp:CustomValidator>
<br />
<br />
<asp:Button ID="Button1" runat="server" Text="Valider"
onclick="Button1_Click" />
<br />
<br />
<asp:HyperLink ID="HyperLink_validee" runat="server" Font-Underline="True"
ForeColor="#009933" NavigateUrl="~/TarifImageHistorique.aspx">Votre demande a bien été enregistrée</asp:HyperLink>
<br />
</div>
</fieldset>
</div>


and here is the CSS :

fieldset
{
margin-bottom:20px;
border:1px solid rgb(149,149,149);
padding: 10px 10px 10px 10px;
width:100%;

}
#container
{
margin-left:auto;
margin-right:auto;
width:400px;
}
.content
{
text-align:center;
}


I don't get why the second FileUpload won't align as the first one. Can anyone enlighten me ?

Answer

Your CustomValidator3 in front of second file upload control needs dynamic displaying so just add Display="Dynamic" and done.

Comments