I am creating a webpage which has been divide into two sides. On the left there is an image and on the right there can be various user inputs. I put the image into a table cell with float left and the inputs into a cell and float right.
Everything look like what I expect until I add a grid on the right using
<tr>
<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1">
</asp:GridView>
</tr>
Then the alignment of the contents on the right all move to the bottom of the left hand side. Can anyone can help me on this how to make it stick back to the right?
Here is my mark-up
<table id="leftT">
<tr id ="table_left" >
<td>
<asp:Image ID="Image1" runat="server" Height="356px" ImageUrl="~/Image/search.jpg" Width="200px" style="vertical-align:text-top"/>
</td>
</tr>
</table>
<table id ="rightT">
<tr>
<td>
<asp:Label ID="lblUserName" runat="server" Text="Label"></asp:Label>
</td>
<td>
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource1" DataTextField="USERNAME" DataValueField="USERNAME">
<asp:ListItem></asp:ListItem>
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SOConnectionString %>" ProviderName="<%$ ConnectionStrings:SOConnectionString.ProviderName %>" SelectCommand="SELECT USERNAME FROM USERMASTER WHERE USERSTATUS = 1 AND USERACCESSRIGHTS = 'Non-Administrator'"></asp:SqlDataSource>
</td>
<td>
<asp:Label ID="lblCreateOnM" runat="server" Text="Label"></asp:Label>
</td>
<td>
<asp:Label ID="lblCreateOn" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblDate" runat="server" Text="Label"></asp:Label>
</td>
<td><asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
<asp:TextBox ID="txtDate" runat="server" Enabled="False"></asp:TextBox>
<asp:Calendar ID="Calendar1" runat="server" OnSelectionChanged="Calendar1_SelectionChanged"></asp:Calendar></td>
<td>
<asp:Label ID="lblUpdateOnM" runat="server" Text="Label"></asp:Label>
</td>
<td>
<asp:Label ID="lblUpdateOn" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblTask" runat="server" Text="Label"></asp:Label>
</td>
<td>
<asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="SqlDataSource2" DataTextField="TASKNAME" DataValueField="TASKNAME">
<asp:ListItem></asp:ListItem>
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:SOConnectionString %>" ProviderName="<%$ ConnectionStrings:SOConnectionString.ProviderName %>" SelectCommand="SELECT DISTINCT TASKNAME FROM TASKMASTER"></asp:SqlDataSource>
</td>
<td>
<asp:Label ID="lblUpdateByM" runat="server" Text="Label"></asp:Label>
</td>
<td>
<asp:Label ID="lblUpdateBy" runat="server" Text="Label"></asp:Label>
</td>
</tr>
</table>
Here The mistake you are doing is, you are creating two tables one below the other.Instead take only one table and two columns and places all the controls in these two columns as shown below
ex-
<table>
<tr>
<td id='Left_id'>
//Put all the left controls here
</td>
<td id='Right_id'>
//Put some controls here if required
<table>
<tr>
<td>
//some Controls Here
</td>
</tr>
</table>
</td>
</tr>
</table>
Related
I'm using a Repeater to create a grid but the grid doesn't fill the width of the screen. It cut offs and leaves blank spaces between the end of the repeater and the border on the right.
I tried setting the last <td> tag to width:100% which did make the line go all the way across but it caused all the other columns to move over to the far left and ruined the layout.
Code:
<tr>
<td style="border-left:1px solid; border-right:1px solid; height:400px" >
<asp:Repeater ID="rptHazDetails" runat="server">
<HeaderTemplate>
<table border="1">
<tr style="border-bottom:1px solid;">
<td>
UN Number, </br>
Proper Shipping Name
</td>
<td style="padding:5px">
Class , </br>
Packing Group
</td>
<td style="padding:5px">
Pieces
</td>
<td style="padding:5px">
Tunnel Code
</td>
<td style="padding:5px">
Gross KG
</td>
<td style="padding:5px">
Net KG
</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr style="border-bottom:1px solid;">
<td style="padding:5px;">
<asp:Label ID="lblUNNumber" runat="server" Text='<%# Eval("UnNumber") %>' /> </br>
<asp:Label ID="lblProper" runat="server" Text='<%# Eval("Packages") %>' />
</td>
<td style="padding:5px;">
<asp:Label ID="lblClass" runat="server" Text='<%# Eval("IMOClass") %>' /> </br>
<asp:Label ID="lblPacking" runat="server" Text='<%# Eval("IMOPage") %>' />
</td>
<td style="padding:5px;">
<asp:Label ID="lblPieces" runat="server" Text='<%# Eval("PieceBreakDown") %>' />
</td>
<td style="padding:5px;">
<asp:Label ID="lblTunnelCode" runat="server" Text='<%# Eval("TunnelCode") %>' />
</td>
<td style="padding:5px;">
<asp:Label ID="lblGrossWeight" runat="server" Text='<%# Eval("GrossWeight","{0:0.##}") %>' />
</td>
<td style="padding:5px;">
<asp:Label ID="lblNetWeight" runat="server" Text='<%# Eval("NetWeight","{0:0.##}") %>' />
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</td>
</tr>
I just want to border lines to reach all the across the screens and don't leave a gap.
I set:
table {
width: 100%;
}
This way the table will cover the entire window. I then can choose to give each column a different width in px or %, the best way is using bootstrap classes. So include in your header
Then you can set a class for example col-md-4 for giving that column a span of 4 columns, you can also hide the column for sm screens and do other effects. Go and check
http://getbootstrap.com/css/#grid
Or ask me more informations
Fabrizio Bertoglio
I have used the captcha refresh button to refresh the captcha code, but the scenario is that when I click on the refresh image, the whole form gets refreshed. Please help. Also see the code below:-
<table style="width: 583px;">
<tr>
<td>Name</td>
<td>
<asp:TextBox ID="TextBox1" runat="server" class="txtfld-popup"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Please enter your Full Name" ControlToValidate="Fullname" Display="Dynamic" Style="font-size: 13px;"></asp:RequiredFieldValidator>
<cc1:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender4" runat="server" TargetControlID="FullName" WatermarkText="Enter Your Full Name"></cc1:TextBoxWatermarkExtender>
</td>
</tr>
<tr>
<td>Contact No.</td>
<td>
<asp:TextBox ID="TextBox2" class="txtfld-popup" runat="server" MaxLength="10" onkeypress="if(event.keyCode<48 || event.keyCode>57)event.returnValue=false;"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Please enter Contact No." Display="Dynamic" ControlToValidate="ContactNo" ValidationExpression="\w+([-+.']\w+)*#\w+([-.]\w+)*\.\w+([-.]\w+)*" Style="font-size: 13px;"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="Please enter valid Contact No." Display="Dynamic" ControlToValidate="ContactNo" ValidationExpression="^\d{10}$" Style="font-size: 13px;"></asp:RegularExpressionValidator>
<cc1:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender5" runat="server" TargetControlID="ContactNo" WatermarkText="Enter Your Contact No."></cc1:TextBoxWatermarkExtender>
</td>
</tr>
<tr>
<td>Purpose </td>
<td>
<asp:TextBox ID="TextBox3" runat="server" class="txtfld-popup" ValidationGroup="VG"></asp:TextBox>
<cc1:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender6" runat="server" TargetControlID="Purpose" WatermarkText="Enter Your Purpose"></cc1:TextBoxWatermarkExtender>
</td>
</tr>
<tr>
<td> </td>
<td>
<div>
<cc1:CaptchaControl ID="CaptchaControl1" runat="server" CaptchaBackgroundNoise="Low" CaptchaLength="5"
CaptchaHeight="60" CaptchaWidth="200" CaptchaMinTimeout="5" CaptchaMaxTimeout="240"
FontColor="#D20B0C" NoiseColor="#B1B1B1" Width="150" />
</div>
<asp:ImageButton ID="ImageButton2" ImageUrl="~/images/refresh.png" runat="server" CausesValidation="false" />
<br />
<asp:TextBox ID="TextBox4" runat="server" MaxLength="5"></asp:TextBox>
<asp:CustomValidator ID="CustomValidator2" ErrorMessage="Invalid. Please try again." OnServerValidate="ValidateCaptcha"
runat="server" />
<p style="margin-top: 3px; margin-bottom: 3px;">
<asp:Label ID="Label1" runat="server"></asp:Label>
</p>
</td>
</tr>
<tr>
<td> </td>
<td>
<asp:Button ID="Button1" runat="server" Text="Submit" OnClick="btnSend_Click" class="button-form" Width="100" />
<asp:Button ID="Button2" runat="server" Text="Reset" OnClick="btnReset_Click" class="button-form" Width="100" CausesValidation="false" /></td>
</tr>
Also see the code behind for your reference:-
protected void ValidateCaptcha(object sender, ServerValidateEventArgs e)
{
Captcha1.ValidateCaptcha(txtCaptcha.Text.Trim());
e.IsValid = Captcha1.UserValidated;
if (e.IsValid)
{
ClientScript.RegisterClientScriptBlock(this.GetType(), "ResponseDialog", "$(document).ready(function(){ResponseDialog();});", true);
SendMail();
}
}
Please help
Finally added a update panel for the solution:-
<tr>
<td> </td>
<td>
<div>
<asp:UpdatePanel ID="updatePanel" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<table>
<tr>
<td>
<cc1:CaptchaControl ID="Captcha1" runat="server" CaptchaBackgroundNoise="Low" CaptchaLength="5"
CaptchaHeight="60" CaptchaWidth="200" CaptchaMinTimeout="5" CaptchaMaxTimeout="240"
FontColor="#D20B0C" NoiseColor="#B1B1B1" />
</td>
<td>
<asp:ImageButton ID="ImgRefreshButton" ImageUrl="~/images/refresh.png" runat="server" CausesValidation="false" />
</td>
</tr>
</table>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ImgRefreshButton" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<asp:TextBox ID="txtCaptcha" runat="server" MaxLength="5"></asp:TextBox>
<asp:CustomValidator ID="CustomValidator1" ErrorMessage="Invalid. Please try again." OnServerValidate="ValidateCaptcha"
runat="server" />
<p style="margin-top: 3px; margin-bottom: 3px;">
<asp:Label ID="lblLeaveNo2" runat="server"></asp:Label>
</p>
</td>
</tr>
And it is working for me. :)
i try to add dropdown in repeater it shows me drodown above in table where as i want to show in status column
code in html
<div class="CSSTableGenerator">
<table border="0" width="100%" cellpadding="0"
cellspacing="0" id="results">
<asp:Repeater ID="Repeater2" OnItemCommand="Repeater2_ItemCommand" runat="server">
<HeaderTemplate>
<tr>
<td>
DocumentID
</td>
<td>
DocName
</td>
<td>
File Name
</td>
<td>
Document
</td>
<td>
Department
</td>
<td>
Status
</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:Label Id="DocId" runat="server"></asp:Label>
<%#DataBinder.Eval(Container.DataItem, "DocID")%>
</td>
<td>
<asp:Label Id="DocName" runat="server"></asp:Label>
<%#DataBinder.Eval(Container.DataItem, "DocName")%>
</td>
<td>
<asp:Label Id="Uploadfile" runat="server"></asp:Label>
<%#DataBinder.Eval(Container.DataItem, "Uploadfile")%>
</td>
<td>
<asp:Label Id="DocType" runat="server"></asp:Label>
<%#DataBinder.Eval(Container.DataItem, "DocType")%>
</td>
<td>
<asp:Label Id="DepType" runat="server"></asp:Label>
<%#DataBinder.Eval(Container.DataItem, "DepType")%>
</td>
<td>
<asp:Label ID="Label1" runat="server"
Text='<%# Eval("ApproveID") %>' Visible = "false" />
<%#DataBinder.Eval(Container.DataItem, "ApproveID")%>
</td>
</tr>
<asp:Label ID="lblCountry" runat="server"
Text='<%# Eval("ApproveID") %>' Visible = "false" />
<asp:DropDownList ID="DropDownList4" runat="server"
EnableViewState="true" class="vpb_dropdown"
DataTextField="ApproveType"
DataValueField="ApproveID" AutoPostBack="true"
OnSelectedIndexChanged="DropDownList4_SelectedIndexChanged">
<asp:ListItem Text="Pending" selected="selected"
Value="3"></asp:ListItem>
<asp:ListItem Text="Approve"
Value="1"></asp:ListItem>
<asp:ListItem Text="Reject"
Value="2"></asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:Repeater>
</table>
<asp:Label ID="apfi" runat="server" Text="Label"></asp:Label><br />
<asp:Button ID="Button4" runat="server" Text="Button" onclick="Button4_Click" />
</div>
</div>
</center>
</div>
pleae have a look image below how i solve this ...where is mistake?
but it shows me like this
image
The mistake is that your DropDownList (and a Label) are between the table and tr elements, which is invalid HTML. The result client-side would be something like this:
<table>
<tr>
<td>...</td>
</tr>
<span>...</span>
<select>
<option>...</option>
</select>
</table>
There's no way to correctly render that because span and select aren't table row elements.
As for how to fix this, that entirely depends on how you want those elements to display. What you've attempted isn't a meaningful layout, so what is the layout you're looking for?
For example, if you want those elements to display in a table cell at the end of the row, you need to add a cell for them:
<table>
<tr>
<td>...</td>
<td>
<span>...</span>
<select>
<option>...</option>
</select>
</td>
</tr>
</table>
If you want them to display outside the table (maybe to the right of it?) then they'd need to be outside the table and you can use CSS to position them. (Alignment would be tricky, though. If they're logically part of the table, which they seem to be given that they're in its repeater, then they should be part of the table itself.)
Table structures have to be structured like a table.
(Note: Any time you have rendering issues like this, the first thing you should do is validate your markup. That would have identified specifically which parts are invalid and referenced the HTML specifications which define those parts.)
I want to align ' : ' vertically, how to do that?
<td>
<b>ID</b>:<asp:Label ID="ID0" runat="server" Text='<%# Bind("ID") %>'></asp:Label>
<br></br>
<b>Name</b>:<asp:Label ID="Name0" runat="server" Text='<%# Bind("Name") %>'></asp:Label>
<br></br>
<b>Age</b>:<asp:Label ID="Age0" runat="server" Text='<%# Bind("Age") %>'></asp:Label>
<br></br>
<b>Height</b>:<asp:Label ID="Height0" runat="server" Text='<%# Bind("Height") %>'></asp:Label>
<br></br>
<b>Education</b>:<asp:Label ID="Education0" runat="server" Text='<%# Bind("Education") %>'></asp:Label>
</td>
</tr>
I simply split the fields and values into columns. Then all you have to do is right-align the field table-cell.
CSS:
.left-column
{
text-align: right;
font-weight: bold;
}
HTML:
<table>
<tr>
<td>
<table>
<tr>
<td class="left-column">
ID:
</td>
<td>
<asp:Label ID="ID0" runat="server" Text='<%# Bind("ID") %>' />
</td>
</tr>
<tr>
<td class="left-column">
Name:
</td>
<td>
<asp:Label ID="Name0" runat="server" Text='<%# Bind("Name") %>' />
</td>
</tr>
<tr>
<td class="left-column">
Age:
</td>
<td>
<asp:Label ID="Age0" runat="server" Text='<%# Bind("Age") %>' />
</td>
</tr>
<tr>
<td class="left-column">
Height:
</td>
<td>
<asp:Label ID="Height0" runat="server" Text='<%# Bind("Height") %>' />
</td>
</tr>
<tr>
<td class="left-column">
Education:
</td>
<td>
<asp:Label ID="Education0" runat="server" Text='<%# Bind("Education") %>' />
</td>
</tr>
</table>
</td>
</tr>
</table>
You have invalid markup as colon(:) doesn't inside b or asp:Label.
change
<b>ID</b>:<asp:Label ID="ID0" runat="server" Text='<%# Bind("ID") %>'></asp:Label>
to this
<b>ID :</b><asp:Label ID="ID0" runat="server" Text='<%# Bind("ID") %>'></asp:Label>
You'll need to use elements that have display:inline-block then you can use vertical-align:middle
EDIT
I misunderstood the question. You could set a minimum width on your <b> tags, but it's not fully cross-browser:
<style>
p b { min-width: 50px; display:inline-block; }
</style>
<p><b>Foo</b>:</p>
<p><b>Bar</b>:</p>
However, as you're using a table anyway, I'd suggest using the table itself to keep things aligned
How do I prevent a table from wrapping when it is inside of an outer table cell?
Have a look at the simplified example at the bottom of my question.
My aspx-tablerow:
<tr runat="server" id="trButtons">
<td align="left" colspan="9" valign="top" style="white-space:nowrap"><br />
<asp:Button ID="btnImeiLookup" OnClick="btnImeiLookupClick" runat="server" ValidationGroup="VG_RMA_LOOKUP" CausesValidation="true" Text="lookup IMEI" ToolTip="lookup IMEI and check if RMA-Number can be generated" Width="120px" />
<asp:Button ID="BtnEdit" CommandName="Edit" CommandArgument='<%# Eval("idRMA")%>' ValidationGroup="VG_RMA_SAVE" runat="server" CausesValidation="false" Text="Edit" ToolTip="edit" Width="120px" />
<asp:Button ID="BtnAdd" runat="server" CommandName="Add" CausesValidation="false" Text="Add new" Width="130px" ToolTip="add new" />
<asp:Button ID="BtnDelete" runat="server" CommandName="Delete" CommandArgument='<%# Eval("idRMA")%>' CausesValidation="true" Text="Delete" Width="120px" ToolTip="delete" OnClientClick="return confirm('do you really want to delete this RMA?')" />
<uc4:RmaPrinterView ID="RmaPrinterView1" Visible="true" runat="server" />
</td>
</tr>
RmaPrinterView1 is an ASP.Net Usercontrol:
<table cellpadding="0" cellspacing="0">
<tr>
<td>
<input type="button" style="width:120px; white-space:nowrap" onclick="javascript:$('#TblPrinterView').jqprint();" value="Print" title="Print" />
</td>
</tr>
<tr>
<td>
<table id="TblPrinterView" style="display:none">
<tr>
<td style="width:100px;white-space:nowrap">
<asp:Label ID="LblRmaNumberDesc" runat="server" Text="RMA-Number:"></asp:Label>
</td>
<td>
<asp:Label ID="LblRmaNumber" runat="server" Text="xxxxxxxxxxxxxx"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="LblImeiDesc" runat="server" Text="IMEI:"></asp:Label>
</td>
<td>
<asp:Label ID="LblImei" runat="server" Text="xxxxxxxxxxxxxx"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="LblModelDesc" runat="server" Text="Model:"></asp:Label>
</td>
<td>
<asp:Label ID="LblModel" runat="server" Text="xxxxxxxxxxxxxx"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="LblSiDpyDesc" runat="server" Text="SI/DPY:"></asp:Label>
</td>
<td>
<asp:Label ID="LblSiDpy" runat="server" Text="xxxxxxxxxxxxxx"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="LblSymptomCodesDesc" runat="server" Text="Symptoms:"></asp:Label>
</td>
<td>
<asp:Label ID="LblSymptomCodes" runat="server" Text="xxxxxxxxxxxxxx"></asp:Label>
</td>
</tr>
</table>
</td>
</tr>
</table>
As you can see, the Usercontrol with the inner table is wrapped:
I know that I should avoid table layout, but I needed a fast working solution ;-)
EDIT: a simplified sample that is also wrapping:
<table>
<tr>
<td style="white-space:nowrap">
<input type="button" value="b1" />
<input type="button" value="b2" />
<input type="button" value="b3" />
<table>
<tr>
<td style="white-space:nowrap"><input type="button" value="in table" /></td>
</tr>
</table>
</td>
</tr>
</table>
UPDATE:
The solution - as Jeroen mentioned - was to make the table an inline element with style="display: inline". The next problem was that I used an ASP.Net UpdatePanel inside the UserControl which is normally rendered as a Div. So the next block-element that causes my table to wrap. I only needed to set the UpdatePanel's RenderMode to Inline what causes it to be rendered as Span.
If the css white-space does not work, you can try to add nowrap="nowrap" to your td, just like you added valign="top".
Very ugly, but it should work.
Edit: Ah, now I see: A table is a block-level element so it will always go to a new line unless you make it an inline-element or float it.
table tr td {
white-space: nowrap;
}
You've put the table at odds with itself. It is set to finite pixel count and yet you don't want to wrap once that's exceeded. You might attempt:
white-space: nowrap;
overflow: hidden;