将fontawesome图标添加到asp.net按钮

时间:2018-03-05 18:09:23

标签: c# asp.net twitter-bootstrap font-awesome font-awesome-5

我正在使用gridview来显示数据,在gridview本身我有一些动作按钮,如图片视图的编辑删除和预览。但我不希望我的预览按钮上的文字“预览”,我想要(fontawesome图标)而不是文本(预览)。我的代码在这里......

<asp:GridView ID="GVProduct" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" CssClass="table table-bordered table-sm table-hover table-striped" EmptyDataText="No rows  for the selection criteria." EnableTheming="False" PageSize="5" OnRowCommand="grdForRows_RowCommand" OnPageIndexChanging="grdForRows_PageIndexChanging">
<Columns>
    <asp:BoundField DataField="ProId" HeaderText="Prod.Id">
        <HeaderStyle HorizontalAlign="Left" />
        <ItemStyle HorizontalAlign="Right" />
    </asp:BoundField>
    <asp:BoundField DataField="ProName" HeaderText="Product Name">
        <HeaderStyle HorizontalAlign="Left" />
        <ItemStyle HorizontalAlign="Left" />
    </asp:BoundField>
    <asp:BoundField DataField="ProCategory" HeaderText="Category">
        <HeaderStyle HorizontalAlign="Left" />
        <ItemStyle HorizontalAlign="Left" />
    </asp:BoundField>
    <asp:ButtonField Text="Preview" ButtonType="Button" HeaderText="Photo" CommandName="btnPreview">
        <ControlStyle CssClass="btn btn-success btn-sm" />
    </asp:ButtonField>
    <asp:ButtonField Text="Edit" ButtonType="Button" CommandName="btnEdit">
        <ControlStyle CssClass="btn btn-primary btn-sm" />
    </asp:ButtonField>
    <asp:ButtonField ButtonType="Button" CommandName="btnDelete" Text="Delete">
        <ControlStyle CssClass="btn btn-danger btn-sm" />
    </asp:ButtonField>
</Columns>

我要在按钮上添加的图标代码是

<i class="fas fa-eye"></i>

3 个答案:

答案 0 :(得分:1)

您可以从Fontawesome下载SVG文件,然后在ImageButton中添加带有“ ImageUrl”标签的文件,如下所示:

<asp:TemplateField>
      <HeaderTemplate>
           <asp:Label ID="Label2" runat="server" Text="Edit" ToolTip="Edit"></asp:Label>
      </HeaderTemplate>
      <ItemTemplate>
           <asp:ImageButton runat="server" ImageUrl="~/context/Imagenes/Edit.svg" ID="Id" 
                CommandName="Command" />
      </ItemTemplate>
</asp:TemplateField>

答案 1 :(得分:0)

我找到了将Private Sub ComboBox1_Change() Sheets("DoNotPrint - Rate Index").Range("C2:AS2") = ComboBox1.Value End Sub 图标添加到Font Awesome按钮的方法。使用GridView

ButtonType="Link"

答案 2 :(得分:-1)

您可以使用图像
DeleteImageUrl = “〜/图片/ remove.png”

它是一个工作的我不知道为什么有人给出否定的

import java.util.*;

public class Test {

    public static void main(String[] args) {
        int scores = 0;
        int numberOfGrades;

        Scanner input = new Scanner(System.in);

        System.out.println("Enter amount:");
        numberOfGrades = input.nextInt();

        double[] amountOfGrades = new double[numberOfGrades];
        amountOfGrades = randomGrades(amountOfGrades /* or: amountOfGrades.length */);
        System.out.println(Arrays.toString(amountOfGrades));

        System.out.println("Letter grades...");

    }

    public static double[] randomGrades(double[] array /* or: int amount */) {
        Random rndm = new Random();
        // add this line if you use int argument: double[] array = new double[amount];
        for(int i = 0; i < array.length; i++) {
            array[i] = (double)(rndm.nextInt(45) + rndm.nextDouble() + 55);
        }
        return array;
    }
}