Make whole <li> as link vb.net - asp.net

I have created a user control that generates list item , how can i make the whole field clickable rather than just a text ( now the hyperlink is wrapped around the merchants name) , wrapping the list in a hyperlink will mess up the entire flow of the table and ive already run out of ideas.
<li>
<div ID="divmech" class = "hint--top" data-hint="" runat="server">
<asp:HyperLink ID="hypTrendingMerchant" CssClass="merchantName-width" runat="server" >
<asp:Label ID="lblMerchantName" runat="server" />
</asp:HyperLink>
<asp:Label ID ="lblMerchantDifference" class="gecko-right gecko-trend-arrow pad gecko-col-secondary" font-bold="true" runat="server" />
</div>
</li>

Wrap your div in the link, and make sure it takes up the whole space of your li:
<li>
<asp:HyperLink ID="hypTrendingMerchant" CssClass="merchantName-width" runat="server" >
<div ID="divmech" class = "hint--top" data-hint="" runat="server">
<asp:Label ID="lblMerchantName" runat="server" />
<asp:Label ID ="lblMerchantDifference" class="gecko-right gecko-trend-arrow pad gecko-col-secondary" font-bold="true" runat="server" />
</div>
</asp:HyperLink>
</li>
What you actually wind up doing here will depend on your layout, but something like this.

<li>
<asp:HyperLink ID="hypTrendingMerchant" CssClass="merchantName-width" runat="server" >
<span ID="divmech" class = "hint--top" data-hint="" runat="server">
<asp:Label ID="lblMerchantName" runat="server" />
<asp:Label ID ="lblMerchantDifference" class="gecko-right gecko-trend-arrow pad gecko-col-secondary" font-bold="true" runat="server" />
</span>
</asp:HyperLink>
</li>
don't put block elements like DIV inside inline elements like A. instead wrap all li content in the link.
then from CSS, make A as block, and if you need the span #divmech as block element, then do that from CSS too. Don't forget to set LI padding to 0 so A element would take most of the space
li{
display:block;
padding:0;
}
a.merchantName-width{
display:block;
}
#divmech{
display:block;
}

Related

Removing empty DDLs from Main Menu using Panels

I have a main menu in which each menu category drops down. It reads the drop down data from a database and there are times when a particular menu option will contain nothing when it is dropped down. I therefore wish to remove that menu option if the drop down list is empty. Here is my code..
<li><a style="color:#fff";">
<asp:DropDownList ID="ddl1" runat="server" style="font-weight: bold; color:#fff;background:#444444; border:0; text-indent: 5%; text-align-last:center; z-index:-1;" class="fixDDLCategorySize" Height="29px" AutoPostBack="True" OnSelectedIndexChanged="ddl1_SelectedIndexChanged" >
</asp:DropDownList></a>
</li>
<li><a style="color:#fff";">
<asp:DropDownList ID="ddl2" runat="server" style="font-weight: bold; color:#fff;background:#444444; border:0; text-indent: 5%; text-align-last:center; z-index:-1;" class="fixDDLCategorySize" Height="29px" AutoPostBack="True" OnSelectedIndexChanged="ddl2_SelectedIndexChanged" >
</asp:DropDownList></a>
</li>
...ETC
In VB, when a menu option is empty I try ddl1.visible=false but it still leaves a block on the screen which the css is causing. I therefore tried this..
<asp:Panel ID="pnl1" runat="server" Visible="true">
<li><a style="color:#fff";">
<asp:DropDownList ID="ddl1" runat="server" style="font-weight: bold; color:#fff;background:#444444; border:0; text-indent: 5%; text-align-last:center; z-index:-1;" class="fixDDLCategorySize" Height="29px" AutoPostBack="True" OnSelectedIndexChanged="ddl1_SelectedIndexChanged" >
</asp:DropDownList></a>
</li>
</asp:Panel>
and then used pnl1.visible=false to remove an empty menu category but all the other menu options then lose all their css.
Is there a way to do this?

ASPX Page formatting

I have Panel that needs to have a button beside it but have been unsuccessful in formatting it. Currently this is what I have.
<asp:Panel runat="server" CssClass="form" ID="panSomeParameters"></asp:Panel>
<asp:Button runat="server" CssClass="form" ID="btnSomeButton" Text="Button" />
Basically I need the Button in the blue area.
You just need to set your Panel display to "inline-block" as panel is rendered as Div and div is a block element so it will cover the whole row. I have set width and height also so panel will contain space on the view.
<asp:Panel runat="server" style="display:inline-block;width:100px;height:20px;" CssClass="form" ID="panSomeParameters"></asp:Panel>
<asp:Button runat="server" CssClass="form" ID="btnSomeButton" Text="Button" />
If it helps then accept the Answer.
You could give them both a class and set the float to left.
<div>
<asp:Panel ID="Panel1" runat="server" CssClass="float-left">
Contents
</asp:Panel>
<asp:Button ID="Button1" runat="server" Text="Button" CssClass="float-left" />
</div>
<style>
.float-left {
float: left;
}
</style>

Increase space between textboxes using CSS

I want to increase the space between two textboxes without using the line break. I've created a CSS rule but it has no effect when displaying the page.
These are the textboxes
<asp:Label ID="Discount" CssClass="textboxcontainer" runat="server" Text="Discount: "></asp:Label><asp:TextBox ID="TextBoxDiscount" runat="server"></asp:TextBox><br />
<asp:Label ID="TotalAfterDis" CssClass="textboxcontainer" runat="server" Text="Total : "></asp:Label><asp:TextBox ID="TextBoxTotal" runat="server"></asp:TextBox> <br />
I have this CSS rule in CSS file
div#page .textboxcontainer{
margin: 10px auto;
Any help is really appreciated
margin doesn't work on asp:label, since asp:label is rendered into span, which is an inline element
Try adding display:inline-block to your css rule.
Your <asp:Label> will render as an HTML span, which displays inline by default, causing top and bottom margin to be ignored. Add display: block or display: inline-block to your .textboxcontainer rule.
ASP Label controls render in a <span> tag at runtime. This is what is giving you trouble. Simply wrap the label and textbox control in their own div and you will get that block separation. Add a class to that div and give it a margin-bottom: XXpx and you are on your way
<div class="form-group">
<asp:Label ID="Discount" CssClass="textboxcontainer" runat="server" Text="Discount: "></asp:Label>
<asp:TextBox ID="TextBoxDiscount" runat="server"></asp:TextBox>
</div>
<div class="form-group">
<asp:Label ID="TotalAfterDis" CssClass="textboxcontainer" runat="server" Text="Total : "></asp:Label>
<asp:TextBox ID="TextBoxTotal" runat="server"></asp:TextBox>
</div>
CSS
.form-group{
margin-bottom: 10px;
}

Why doesn't CssClass work when a regular class does?

In my CSS file I have:
.Center
{
position:relative;
width:800px;
margin-left: auto;
margin-right: auto;
}
Then, when I have the following all is well:
<div class="Center">
<asp:ImageButton ID="ImageButton1" ImageUrl="..." runat="server" />
</div>
But if I remove the div and add a CssClass instead - it ignores the class:
<asp:ImageButton ID="ImageButton1" ImageUrl="..." runat="server" CssClass="Center" />
Why?
Because an asp:ImageButton renders out as <input type="image" ... />. Your first example has a <div> wrapping the image button, and the styling is applied on the <div>. Your second example is attempting to style the <input type="image" ... /> directly (which doesn't work because it's not a block element).
You can use an <asp:Panel> (which renders as a <div>) for equivalent code:
<asp:Panel runat="server" CssClass="Center">
<asp:ImageButton ID="ImageButton1" ImageUrl="..." runat="server" />
</asp:Panel>
Or, change your CSS to work with an <input type="image"> - I think that's as easy as just adding display: block, and the other properties will work the same as a containing <div> would.

Horizontal orientation in Repeater control

I have a Repeater control used to display uploaded images.
How can I show the images in the repeater horizontally? How can i give the caption to the bottom of picture in this?
assuming you have some code like this:
<asp:repeater ...>
</asp:repeater>
just inject "<itemtemplate>" with some html code with the look and feel you want to. nothing special about showing horizontal or vertical it just depends on what html tags you use inside item templates.
If you don't especially need a Repeater to do this, you can use a DataList instead and set the RepeatDirection="Horizontal"
how to display horizontal line after each row
<asp:DataList ID="dlstmovie" runat="server" onitemcommand="dlstmovie_ItemCommand" RepeatColumns="5" ItemStyle-CssClass="item1" RepeatDirection="Horizontal" onitemdatabound="dlstmovie_ItemDataBound" >
<ItemTemplate>
<asp:LinkButton ID="lnkimg" runat="server" CommandName="m1" CommandArgument='<%# DataBinder.Eval(Container.DataItem,"cinemaid")%>'>
<img src='<%=cinemaposter %><%#Eval("picturenm")%>' class="img" />
</asp:LinkButton>
<br />
<asp:LinkButton ID="lnkmovie" runat="server" CommandName="m1" CommandArgument='<%# DataBinder.Eval(Container.DataItem,"cinemaid")%>' Text='<%#(Eval("cinemanm").ToString().Length>10)?(Eval("cinemanm").ToString().Substring(0,10))+"":Eval("cinemanm").ToString()%>' CssClass="blacktext"></asp:LinkButton>
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="m1" CommandArgument ='<%#DataBinder.Eval(Container.DataItem,"cinemaid")%>' Font-Underline="false" CssClass="blacktext">...</asp:LinkButton>
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="lblEmptyData" Text="No Data To Display" runat="server" Visible="false" CssClass="blacktext">
</asp:Label>
</FooterTemplate>
</asp:DataList>
You can build your ItemTemplate like:
<ItemTemplate>
<div class="floating">
<img src='<%# /* Code to Eval your image src from datasource */ %>' alt='' />
<span><%# /* Code to Eval your image caption from datasource */ %></span>
</div>
</ItemTemplate>
where the .floating class of the div is:
.floating { float:left; overflow:hidden; }
.floating img { display: block; }
I usually put a div for clear after a sequence of floating element, to reset the state of box model.
<div style="clear:both;"></div>
Depends on what you are using to display, i.e. if your pictures are in a div put float:left; on it, or use the DataList.
Like #numenor said in this other answer, it's just a matter of what html you use. Here, an example of how to acomplish what you need using html tables.
<table width="<%= this.TotalWidth %>">
<tr>
<asp:Repeater runat="server" ID="rptABC" OnItemDataBound="rptABC_ItemDataBound">
<ItemTemplate>
<td class="itemWidth">
Your item goes here and will be
displayed horizontally as a column.
</td>
</ItemTemplate>
</asp:Repeater>
</tr>
</table>
Note that the width is handled with a server side property TotalWidth that calculates the total width needed based on, of course, the count of items repeater will display. Creating a CSS class to define the width of each item is also recomended to ensure proper layout.
protected string TotalWidth
{
get
{
//In this example this.Madibu.Materiales is the datasource for the Repeater,
//so this.Madibu.Materiales.Count is the column count for your table.
//75 must be equal to the width defined in CSS class 'itemWidth'
return (this.Madibu.Materiales.Count * 75).ToString() + "px";
}
}

Resources