ItemTemplate in Listview - Layout issue - asp.net

I have the following Listview in my aspx page
<asp:ListView ID="ListView1" GroupItemCount="4" runat="server"
DataKeyNames="contentid" DataSourceID="sqldsPhotos">
<LayoutTemplate>
<asp:Placeholder
id="groupPlaceholder"
runat="server" />
</LayoutTemplate>
<GroupTemplate>
<div>
<asp:Placeholder
id="itemPlaceholder"
runat="server" />
</div>
</GroupTemplate>
<ItemTemplate>
<asp:Image id="picAlbum" runat="server"
ImageUrl='<%# "ShowImage.ashx?id=" + Convert.ToString(Eval("contentid")) %>'
Height="108" Width="192" />
<asp:LinkButton ID="LinkButton1" runat="server">LinkButton</asp:LinkButton>
</ItemTemplate>
<EmptyItemTemplate>
</EmptyItemTemplate>
</asp:ListView>
The resulting webpage displays my image with the link button beside it. What I would like is the image with the Linkbutton centered below it for each item.
Can someone help me out with the necessary html or css to achieve this.

Try the following html inside ItemTemplate
<div style="float: left; margin-left: 10px; text-align:center;width: 192; ">
<asp:Image id="picAlbum" runat="server"
ImageUrl='<%# "ShowImage.ashx?id=" + Convert.ToString(Eval("contentid")) %>'
Height="108" Width="192" />
<asp:LinkButton ID="LinkButton1" runat="server"
style="display: block; clear: both;">LinkButton</asp:LinkButton>
</div>
The above code will show divs side by side. So inorder to show 4 divs add with (800px) to your items in list view.
If you don't get the linkbutton at center add some margin-left to it to show it at center.

Try this:
<div style="width: 192px; text-align:center;">
<asp:Image id="picAlbum" runat="server"
ImageUrl='<%# "ShowImage.ashx?id=" + Convert.ToString(Eval("contentid")) %>'
Height="108" Width="192" /><br/>
<asp:LinkButton ID="LinkButton1" runat="server">LinkButton</asp:LinkButton>
</div>

Related

how to give marquee to a hyperlink in repeater control

I want to show some scrolling(marquee) link in my Website form to
display data I am using repeater control.but when i am trying to give
marquee to the repeater it doesn't give me output How I give marquee
Please help. My code:
<div id="calendar1">
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:CBMIAConnectionString %>"
SelectCommand="SELECT Event FROM [Home_EventLink]"></asp:SqlDataSource>
<table id="Head_Meeting">
<tr>
<td style="font-size: large; font-weight: bold; font-family: Arial, Helvetica, sans-serif; text-transform: capitalize; color: white;">&nbsp&nbsp<i class="fas fa-calendar-alt" style="font-size: 25px; color: white"></i>&nbsp Upcoming Meetings</td>
</tr>
</table>
<br />
<div id="Meeting_Event" padding-left="5px" padding-right="5px">
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" class="hyperlink" Text='<%# Eval("Event") %>' href="home.aspx" runat="server" /><br />
</ItemTemplate>
<SeparatorTemplate>
<hr />
</SeparatorTemplate>
</asp:Repeater>
</div>
</div>
THIS MAY HELP
<marquee id="MyMovingText" style="width: 80%" scrollamount="5" onmouseover="stop();" onmouseout="start();" runat="server" direction="left">
<asp:datalist RepeatDirection="Horizontal" ID="rptbreaknews" runat="server">
<ItemTemplate>
<a class="readmore" target="_blank" href='<%#"details.aspx?Id="+Eval("Id") %>'>
<h3><asp:Label ID="lbltext" Text='<%#Eval("NewNewsTitle") %>' runat="server"></asp:Label></h3>
</a>
</ItemTemplate>
</asp:datalist>
</marquee>
You can use marquee like this. And do not use class and href within an aspnet Control but use the correct properties like CssClass and NavigateUrl
<marquee id="MyMovingText" direction="left" scrollamount="10">
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<div class="scroll-item">
<asp:HyperLink ID="HyperLink1" CssClass="hyperlink" Text='<%# Eval("Event") %>'
NavigateUrl="/home.aspx" runat="server" />
</div>
</ItemTemplate>
</asp:Repeater>
</marquee>
<style>
.scroll-item {
float: left;
margin-right: 50px;
}
</style>

how to maintain DIV scroll bar position in Listview ASP.net

my problem is when i click the imagebutton ("imgEdit") in the listview the scroll bar of my listview doesnt stay in the position where i click it.
heres my code:
<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:ListView ID="LV_Profile" runat="server" GroupItemCount="1" GroupPlaceholderID="groupPlaceHolder1"
ItemPlaceholderID="itemPlaceHolder1" OnItemDataBound="LV_Profile_ItemDataBound" OnSelectedIndexChanged="LV_Profile_SelectedIndexChanged" >
<LayoutTemplate>
<div id ="mainprofile" style="overflow-x: scroll; margin: 0 65px;" runat="server">
<div id="subdivprof" runat="server" style="height: inherit; width: 3400px; margin: 10px 0;">
<asp:PlaceHolder runat="server" ID="groupPlaceHolder1"></asp:PlaceHolder>
</div>
</div>
</LayoutTemplate>
<GroupTemplate>
<asp:PlaceHolder runat="server" ID="itemPlaceHolder1"></asp:PlaceHolder>
</GroupTemplate>
<ItemTemplate>
<div class="divprofile">
<div id="proftools" class="tools" runat="server">
<asp:ImageButton ID="imgCancel" CssClass="img"
ImageUrl="~/images/Delete-52 (1).png" runat="server" alt=""
ToolTip="Cancel edit" Visible="False" OnClick="DoneEdit" />
<asp:ImageButton ID="imgDone" CssClass="img"
ImageUrl="~/images/Checkmark-52.png" runat="server" alt=""
ToolTip="Done edit" Visible="False" />
<asp:ImageButton ID="imgEdit" CssClass="img" ImageUrl="~/images/Edit User Male-52.png"
runat="server" alt="" ToolTip="Edit profile" OnClick = "EditUser" />
<asp:ImageButton ID="imgEmail" CssClass="img" ImageUrl="~/images/-Message Filled-52.png"
runat="server" alt="" ToolTip="Send an email" />
</div>
<div id="proginfo" runat="server">
<div class="level"><%#Eval("Prog_Pos")%></div>
<div class="pic"><asp:ImageButton ID="ImageButton1" CssClass="img" runat="server" onclick="FindUser" OnClientClick="return chooseFile();" ToolTip='<%#Eval("Idno")%>' Enabled="False" /></div>
<div class="nickname"><asp:Textbox ID="txtNickname" runat="server" Text='<%#Eval("NickName") %>' CssClass="txt" Enabled="false" style="margin-top:10px;"></asp:Textbox></div>
<div class="name"><asp:TextBox ID="txtName" runat="server" Text='<%#Eval("Name")%>' CssClass ="txt" Enabled="false" ></asp:TextBox></div>
<div class="email"><asp:Textbox ID="txtEmail" runat="server" Text='<%#Eval("emailAddress")%>' CssClass="txt" Enabled="false"></asp:Textbox></div>
</div>
</div>
</ItemTemplate>
</asp:ListView>
</ContentTemplate>
</asp:UpdatePanel>
Thanks in advance. :)
You need after update return list position.
Add in .aspx
<asp:HiddenField id="scrollPosition" runat="server"/>
Next you need in JS
find this hiddenfield
var hdField = document.getElementById(<%=scrollPosition.ClientID%>);
find list
var list= document.getElementById('LV_Profile');
OnScroll event set value to your HiddenField
list.onscroll = function() {
hdField .value = list.scrollTop;
}
When window or document is onload return saved position
window.onload = function () {
list.scrollTop = hdField.value;
}

How do I get a toggle button and text to stack vertically so that their centres align?

I have the following code to create a "favourites" button:
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" />
<asp:ToggleButtonExtender ID="ToggleButtonExtender1" runat="server"
TargetControlID="CheckBox1"
ImageWidth="24"
ImageHeight="24"
UncheckedImageUrl="~/ClientBin/images/icons24x24/openstar.png"
CheckedImageUrl="~/ClientBin/images/icons24x24/filledstar.png"
CheckedImageAlternateText="Check"
UncheckedImageAlternateText="UnCheck"></asp:ToggleButtonExtender>
<br />
<asp:Label runat="server"
Text="Favourite"
font-size="8"
font-name="Verdana"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
</div>
Which gives me the following layout on the page:
What I would like is for the elements to be aligned something like this:
with the star's and text's centre's aligned.
I feel I'm missing something obvious, but I can't find the right search terms to reveal the answer.
This may not be ideal, but you can place the Checkbox and ToggleButtonExtender in a table of a certain size, and then nudge the image to the right using cell padding:
<div style="margin-left: 1in; margin-top: 1in; width: 24px; text-align: center">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<table style="width: 75px">
<tr>
<td style="padding-left: 12px">
<asp:CheckBox ID="CheckBox1" runat="server" />
<asp:ToggleButtonExtender ID="ToggleButtonExtender1" runat="server"
TargetControlID="CheckBox1"
ImageWidth="24"
ImageHeight="24"
UncheckedImageUrl="star_24x24.bmp"
CheckedImageUrl="star_24x24.bmp"
CheckedImageAlternateText="Check"
UncheckedImageAlternateText="UnCheck">
</asp:ToggleButtonExtender>
</td>
</tr>
</table>
<asp:Label runat="server"
Text="Favourite"
Font-Size="8"
font-name="Verdana"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>

how to select last page on a radlistview datapager

I have a radlistview which has the datapager enabled...
But when I launch the website it currently loads the first datapage on the listview (i.e the first page of comments). Is there a way to change this so that it opens the last page?
Here is the current radlistview...
<telerik:RadListView ID="RadListViewComments" runat="server" AllowPaging="True" DataKeyNames="ID" DataSourceID="SqlDataSourceComments" PageSize="5">
<LayoutTemplate>
<div class="RadListView RadListViewFloated RadListView_Default">
<div class="rlvFloated rlvAutoScroll">
<div id="itemPlaceholder" runat="server">
</div>
</div>
<telerik:RadDataPager ID="RadDataPager1" runat="server">
<Fields>
<telerik:RadDataPagerButtonField FieldType="Numeric" />
</Fields>
</telerik:RadDataPager>
</div>
<ItemTemplate>
<div class="rlvI" style="width: 700px; margin-bottom: 50px" margin-right: 100%>
<asp:Label ID="ownerLabel" runat="server" Text='<%# Eval("owner") %>' /> &nbsp - &nbsp
<asp:Label ID="dateLabel" runat="server" Text='<%# Eval("commentdate")%>' />
<br />
<asp:Label ID="commentLabel" runat="server" Text='<%# Eval("comment") %>' />
</div>
</ItemTemplate>
<EmptyDataTemplate>
<div class="RadListView RadListView_Default">
<div class="rlvEmpty">
There are no previous comments.</div>
</div>
</EmptyDataTemplate>
</telerik:RadListView>
Thanks
In the code-behind you can fire a command event with the "Last" argument on PageLoad to force it to go to the last page.
See
how change the RadDataPager Page# From CodeBehind (server-side)
http://www.telerik.com/help/aspnet-ajax/datapager-overview.html

How to align objects vertically in ASP.NET?

I have been messing around with asp.net for awhile now and always have issues aligning objects with various heights on the same row. For example, in this case, I have a search label, a text field, then a image button. What is the "proper way" to get these three items to align properly?
My existing code:
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<asp:Panel VerticalAlign="Center" runat="server">
<asp:Label ID="Label1" runat="server" Font-Size="X-Large" Text="Search Tests:"></asp:Label>
<asp:TextBox ID="searchTextBox" runat="server" Font-Size="X-Large"
Height="30px" style="margin-left: 13px; margin-top: 0px" Width="219px"></asp:TextBox>
<asp:ImageButton ID="ImageButton2" runat="server" Height="45px"
ImageUrl="~/Images/SearchButton.PNG" style="margin-left: 18px; margin-top: 0px"
Width="95px" />
</asp:Panel>
</asp:Content>
The easiest is using CSS or tables. I put a div around with a height and vertical align to the top. CSS Reference
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<asp:Panel ID="Panel1" VerticalAlign="Center" runat="server">
<div style="height: 40px; vertical-align: top">
<div style="padding-top: 10px; float:left;">
<asp:Label ID="Label1" runat="server" Font-Size="X-Large" Text="Search Tests:"></asp:Label>
</div>
<div style="padding-top: 5px; float:left;">
<asp:TextBox ID="searchTextBox" runat="server" Font-Size="X-Large" Height="30px"
Style="margin-left: 13px; margin-top: 0px" Width="219px"></asp:TextBox>
</div>
<div style="padding-top: 5px; float:left;">
<asp:ImageButton ID="ImageButton2" runat="server" Height="45px" ImageUrl="~/Images/SearchButton.PNG"
Style="margin-left: 18px; margin-top: 0px" Width="95px" />
</div>
</div>
</asp:Panel>
</asp:Content>
i had the same problem and i think that using a table or a div only to align the Textbox it's excessive.
I solved simply:
<asp:TextBox ID="TextBox2" runat="server" Width="60px"></asp:TextBox>
<asp:ImageButton ID="ImageButton1" runat="server"
ImageUrl="~/imatges/imgNou.png"
CssClass="style3" ImageAlign="AbsBottom" />
And adding the margin-top in Design view, the IDE added:
.style3
{
margin-top: 6px;
}

Resources