简体   繁体   中英

Working with ASP.Net Web Forms Views

I have this code in my view page

<asp:HyperLink ID="hyperlink_TruckList" runat="server" 
     Text="Truck List" NavigateUrl="~/View/Trucklist.aspx" 
     Font-Underline="false"></asp:HyperLink>

How to add -

class="col-sm-4" 
style="text-align: center; font-size: 18px; color: black; height: 40px; padding-top: 8px; background: #E8D73E">

and

<i class="glyphicon glyphicon-home"></i> 

on it?

Server Control CssClass and Style property are equivalent to HTML class and style attribute respectively.

<asp:HyperLink ID="hyperlink_TruckList" runat="server" Text="Truck List" NavigateUrl="~/View/Trucklist.aspx" Font-Underline="false" CssClass="col-sm-4" Style="text-align: center; font-size: 18px; color: black; height: 40px; padding-top: 8px; background: #E8D73E">
     <i class="glyphicon glyphicon-home"></i>
</asp:HyperLink>

Firstly add this in your css file

.need
{
text-align: center; font-size: 18px; color: black; 
height: 40px; padding-top: 8px; background: #E8D73E;
}

and then simply write this code

<asp:HyperLink ID="hyperlink_TruckList" runat="server" 
 Text="Truck List" NavigateUrl="~/View/Trucklist.aspx" CssClass="col-sm-4 need"
 Font-Underline="false">
        <i class="glyphicon glyphicon-home"></i> 
</asp:HyperLink>

You can append styles programmatically

hyperlink_TruckList.Style.Add("class", "col-sm-4");
hyperlink_TruckList.Style.Add("style", "text-align: center; font-size: 18px; color: black; height: 40px; padding-top: 8px; background: #E8D73E");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM