I cannot figure out how to align the calendar in the middle of a page.
Here is my code:
<div style="text-align:center">
<asp:Calendar ID="Calendar1" runat="server" BackColor="White" BorderColor="White" BorderWidth="1px" Font-Names="Verdana" Font-Size="9pt" ForeColor="Black" Height="190px" NextPrevFormat="FullMonth" Width="350px">
<DayHeaderStyle Font-Bold="True" Font-Size="8pt" />
<NextPrevStyle Font-Bold="True" Font-Size="8pt" ForeColor="#333333" VerticalAlign="Bottom" />
<OtherMonthDayStyle ForeColor="#999999" />
<SelectedDayStyle BackColor="#333399" ForeColor="White" />
<TitleStyle BackColor="White" BorderColor="Black" BorderWidth="4px" Font-Bold="True" Font-Size="12pt" ForeColor="#333399" />
<TodayDayStyle BackColor="#CCCCCC" VerticalAlign="Middle" HorizontalAlign="Center" />
</asp:Calendar>
<br />
</div>
Change your div style to this:
<div style="width:X%; margin: 0 auto;">
Set X to be the same as the width attribute for your calendar.
You can also change your calendar's width attribute to be 100% instead of a pixel amount, and then set the width attribute of your div to 50%. You can then toy with those to get them to look any way you want.
Related
I need help restricting the 'Link target' column inside this gridview. If a long URL string is entered the page will stretch outside of the panel and give the webpage a deformed look.
I can restrict the column width by setting the HeaderStyle width but it does not stop a long URL string.
I can edit the width, but even with an adjusting width the cell will not restrict the size of the actual content.
<asp:GridView ID="gvRefLinks" runat="server" AutoGenerateColumns="False" CellPadding="4" DataKeyNames="PRL_ID" DataSourceID="sqlDsRefLinks" ForeColor="#333333" GridLines="None" Width="100%" AllowSorting="True">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:BoundField DataField="PRLT_TypeName" HeaderText="Link Type" SortExpression="PRLT_TypeName" >
<HeaderStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:TemplateField HeaderText="Link Target" SortExpression="PRL_LinkTarget">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("PRL_LinkTarget") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:HyperLink ID="hlLinkTarget" runat="server" Target="_blank" Text='<%# Eval("PRL_LinkTarget") %>' Visible="False"></asp:HyperLink>
<asp:LinkButton ID="lbLinkTarget" runat="server" CommandArgument='<%# Eval("PRL_LinkTarget") %>' CommandName="EPDM" Text='<%# Eval("PRL_LinkTarget") %>' Visible="False"></asp:LinkButton>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Left" />
</asp:TemplateField>
<asp:BoundField DataField="PRL_Description" HeaderText="Link Description" SortExpression="PRL_Description" >
<HeaderStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:CommandField ShowDeleteButton="True">
<ItemStyle ForeColor="Blue" HorizontalAlign="Right" />
</asp:CommandField>
</Columns>
<EditRowStyle BackColor="#2461BF" />
<EmptyDataTemplate>
No reference links have been specified for the current project.
</EmptyDataTemplate>
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" HorizontalAlign="Left" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
I want to force the 'Link Target' row to a certain width and if the string exceeds that width, I want to have the rest of the string wrapped or hidden.
Try to add the following css class to hlLinkTarget and lbLinkTarget:
.truncate {
width: 150px; /* set the desired width */
display: inline-block;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
i have used one template field for add edit, update, delete and cancel image icons. but edit and delete template field width is small and these two images are displaying on by one vertically due to less width . how to increase width of template field so that it can display two images in one line horizontally
<asp:TemplateField>
<ItemStyle Width="80px" />
<HeaderStyle Width="80px" />
<FooterStyle Width="80px" />
<ItemTemplate>
<asp:ImageButton ID="btnEdit" runat="server" CommandName="Edit" ImageUrl="img/edit.png" ToolTip="Edit" />
<asp:ImageButton ID="btnDelete" runat="server" CommandName="Delete" ImageUrl="img/delete.PNG" ToolTip="Delete" />
</ItemTemplate>
<EditItemTemplate>
<asp:ImageButton ID="btnUpdate" runat="server" CommandName="Update" ImageUrl="img/icon-update.png" ToolTip="Update" Height="18px" Width="18px" />
<asp:ImageButton ID="btnCancel" runat="server" CommandName="Cancel" ImageUrl="img/icon-Cancel.png" ToolTip="Cancel" CausesValidation="false" Height="16px" Width="16px" />
</EditItemTemplate>
</asp:TemplateField>
You may need to wrap your buttons in a div, with a CSS style to set the width.
Define a selector in your stylesheet as follows:
.buttonColumnWidth
{
width: 80px; /* change this value as required */
}
Then, make these changes to your Gridview:
<asp:TemplateField>
<ItemStyle Width="80px" />
<HeaderStyle Width="80px" />
<FooterStyle Width="80px" />
<ItemTemplate>
<div class="buttonColumnWidth">
<asp:ImageButton ID="btnEdit" runat="server" CommandName="Edit" ImageUrl="img/edit.png" ToolTip="Edit" />
<asp:ImageButton ID="btnDelete" runat="server" CommandName="Delete" ImageUrl="img/delete.PNG" ToolTip="Delete" />
</div>
</ItemTemplate>
<EditItemTemplate>
<div class="buttonColumnWidth">
<asp:ImageButton ID="btnUpdate" runat="server" CommandName="Update" ImageUrl="img/icon-update.png" ToolTip="Update" Height="18px" Width="18px" />
<asp:ImageButton ID="btnCancel" runat="server" CommandName="Cancel" ImageUrl="img/icon-Cancel.png" ToolTip="Cancel" CausesValidation="false" Height="16px" Width="16px" />
</div>
</EditItemTemplate>
</asp:TemplateField>
I write this html code into my webform.aspx:
<td class="auto-style1">
<asp:GridView ID="GridView1" AutoGenerateSelectButton="True" runat="server" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" style="direction: rtl" CellPadding="4" ForeColor="#333333" GridLines="None">
<AlternatingRowStyle BackColor="White" />
<FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
<RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
<SortedAscendingCellStyle BackColor="#FDF5AC" />
<SortedAscendingHeaderStyle BackColor="#4D0000" />
<SortedDescendingCellStyle BackColor="#FCF6C0" />
<SortedDescendingHeaderStyle BackColor="#820000" />
</asp:GridView>
</td>
How can i show in my table column fit height and width?
I'll post here since I cannot comment yet.
I am sorry but your question isn't much clear, so I'll give my shot.
If you're talking about row height, your best options would be to give a cssclass to your RowStyle and AlternatingRowStyle. Now thats only for rows, if you want to give a style to your columns, you need to work with TemplateField. Usually just adjusting the header column width helps, but you can add our cssclass to each item inside the template field. Ex:
<asp:TemplateField HeaderText="Item1" SortExpression="Item1" ItemStyle-CssClass="Col1">
<ItemTemplate>
Something
</ItemTemplate>
</asp:TemplateField>
OR
<asp:TemplateField HeaderText="Item1" SortExpression="Item1">
<ItemTemplate>
Something
</ItemTemplate>
<ItemStyle CssClass="Col1" />
</asp:TemplateField>
and then on your stylesheet name something like this:
.Col1 {
width: 100px;
}
I have a GridView. I am not adding any style in it but still it's giving me blue color header labels. How can I fix it.
My GridView is as follow.
<asp:GridView ID="grdViewApp" runat="server" AutoGenerateColumns="False" DataKeyNames="APPLICATION_ID,APPNAME,APPDESCRIPTION,REMARKS,VERSION,SCHEDULE_ID,AUTHENTICATION_TYPE"
BorderStyle="None" BorderWidth="0px" Width="100%" BorderColor="Transparent" OnRowCommand="grdViewApp_RowCommand"
OnSorting="grdView_Sorting" AllowSorting="true" AllowPaging="true" PageSize="4"
OnPageIndexChanging="grdViewApp_PageIndexChanging" OnRowDataBound="grdViewApp_RowDataBound">
<AlternatingRowStyle CssClass="AltRow" />
<HeaderStyle HorizontalAlign="Left" />
<RowStyle CssClass="Row" />
<Columns>
<asp:TemplateField HeaderText="Edit" ItemStyle-HorizontalAlign="left" ItemStyle-Width="5%">
<HeaderStyle HorizontalAlign="Left" />
<ItemTemplate>
<asp:ImageButton ImageUrl="~/images/edit-icon.png" ID="ImgBtnEditApp" runat="server"
Height="18" Width="18" CommandArgument='<%# DataBinder.Eval(Container, "RowIndex") %>'
CommandName="EditApp" title="Edit Record" />
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" Width="5%" />
</asp:TemplateField>
<asp:BoundField DataField="APPLICATION_ID" HeaderText="ID" ReadOnly="True" SortExpression="APPLICATION_ID">
<ItemStyle Width="15%" HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField DataField="AppName" HeaderText="Names" SortExpression="AppName">
<ItemStyle Width="15%" HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField DataField="AppDescription" HeaderText="Description" SortExpression="AppDescription">
<ItemStyle Width="15%" HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField DataField="Version" HeaderText="Version" SortExpression="Version">
<ItemStyle Width="15%" HorizontalAlign="Left" />
</asp:BoundField>
</Columns>
</asp:GridView>
The grid uses a table element as the header, plus since you have sorting enabled it also uses a header text with a link, so likely the style is coming from the header link. You will have to use CSS to style the link to use another color.
I have a doubt in gridview design can anyone help me.
I have created a gridview, but when im giving any text to that grid cell my grid design is changing. My question is how to give a fixed height to the gridview even if we are entering text into one cell or no: of cells. And Here is my code.
Thank You in Advance.
<asp:GridView ID="GrvSchoolName1" runat="server" AllowPaging="True" PageSize="4" Height="30px" BackColor="White"
BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" CellPadding="3"
GridLines="Vertical" CssClass="grvclass"
AutoGenerateColumns="False"
ForeColor="Black" onpageindexchanging="GrvSchoolName1_PageIndexChanging">
<PagerSettings Mode="NumericFirstLast" PageButtonCount="4" FirstPageText="First" LastPageText="Last"/>
<AlternatingRowStyle BackColor="#CCCCCC" />
<Columns>
<asp:TemplateField HeaderText="Emergency Alert" HeaderStyle-Height="30px">
<ItemTemplate>
<div style="overflow:auto; height:60px;">
<asp:Label ID="Label1" runat="server" Text='<% #Eval("AlertMessage") %>' ></asp:Label>
</div>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#CCCCCC" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#808080" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#383838" />
</asp:GridView>
</div>
Give a css class to your itemstyle template. Same works for the header :)
.NET
<ItemStyle CssClass="items"> </ItemStyle>
<ItemTemplate>
your stuff
</ItemTemplate>
CSS.
.items{width:200px;}