2016-10-10 3 views
0

방금 ​​다운로드 한 아이콘으로 편집/세부 정보/삭제를 대체하고 싶습니다. 아이콘의 크기는 512x512이며 문제가됩니까? 코드에서 크기를 조정할 수 있습니까 (일부) 또는 일부 프로그램을 사용하여 크기를 조정해야합니다. 그물을 통해 검색을 해봤는데 C# 코드의 매우 긴 부분을 발견했지만 이러한 속성의 텍스트를 아이콘으로 바꾸려면 어디에 넣어야할지 모릅니다. 여기 아이콘으로 편집/세부 정보/삭제 바꾸는 MVC

내 HTML입니다 :

@using PagedList.Mvc; 
@model PagedList.IPagedList<Rating_System.Models.tblTeacher> 
<link href="~/Content/PagedList.css" rel="stylesheet" type="text/css" /> 
@{ 
    ViewBag.Title = "Teachers List"; 
    Layout = "~/Views/Shared/_Layout.cshtml"; 
} 

<h2>Teachers</h2>  
<p> 
    @Html.ActionLink("Add new", "Create") 
</p> 
@using (Html.BeginForm("Index", "Teachers", FormMethod.Get)) 
{ 

<p> 
    Търсене: @Html.TextBox("SearchString", ViewBag.CurrentFilter as string) 
    <input type="submit" value="Search" /> 
</p> 
} 
<table class="table">  
    <tr> 
     <th>     
     </th> 
     <th> 
      @Html.DisplayNameFor(model => model.First().FirstName)  
     </th> 
     <th> 
      @Html.DisplayNameFor(model => model.First().SecondName) 
     </th> 
     <th> 
      @Html.DisplayNameFor(model => model.First().Title) 
     </th>      
     <th></th> 
    </tr> 

    @foreach (var item in Model) 
    { 
     <tr> 
      <td> 
       <img src="@Url.Action("GetImage", "Teachers", new {item.ID})" width="45" height="45" /> 
      </td> 
      <td> 
       @Html.DisplayFor(modelItem => item.FirstName) 
      </td> 
      <td> 
       @Html.DisplayFor(modelItem => item.SecondName) 
      </td> 
      <td> 
       @Html.DisplayFor(modelItem => item.Title) 
      </td>    
      <td> 
       @Html.ActionLink("Редактирай", "Edit", new { id = item.ID }) | 
       @Html.ActionLink("Детайли", "Details", new { id = item.ID }) | 
       @Html.ActionLink("Изтрий", "Delete", new { id = item.ID }) 
      </td> 
     </tr> 
    }  
</table> 

@Html.PagedListPager(Model, page => Url.Action("Index", new { page, pageSize = Model.PageSize })) 
Results @Model.FirstItemOnPage - @Model.LastItemOnPage от общо @Model.TotalItemCount Teachers 
+0

으로 시도 @Html.ActionLink ("Редактирай", "편집", 새로운 {id = item.ID})'를''으로 변경하거나 이미지를 렌더링하기 위해 사용자 정의 HTML 헬퍼를 생성하십시오. 제공된 모든 이미지는 width 및 height 속성을 모두 설정하여 크기를 조정해야합니다. –

답변

0

이 코드

<a href="@Url.Action("ActionName", "ControllerName", new { id = item.ID })"> 
    <img src="@Url.Content("~/Content/imgname.jpg")" /> 
</a> 
+0

나는 그것이 원하는대로 일했다! – Georgi93

0

당신이 아이콘 (이미지) 다음 코드를 사용 사용하려면 : 당신은 배경 이미지를 포함하는 클래스를 CSS

@Html.ActionLink("Редактирай", "Edit", new { id = item.ID }, new { @class="class" }) 

그런 다음 쓰기

a.class 
{ 
background: url(../Images/image.gif) no-repeat top left; 
width: 50px; 
height: 50px; 
display: block; 
text-indent: -9999px; /* hides the link text */ 
} 

그러나 부트 스트랩 글리 phicons를 사용하는 것이 좋습니다

당신은 자바 스크립트 함수를 통해 ID를 전달할 수 있습니다

function JavascriptFunction() { 
window.location.href = encodeURI("/Controller/Action/"); 
} 

<a href="@Url.Action("Action", "Controller")" class="btn btn-info"> 
Your link text 
<span class="glyphicon glyphicon-time" aria-hidden="true"></span> 
</a> 

또는

<span class="glyphicon glyphicon-ok" style="cursor:pointer" onclick="JavascriptFunction()"></span> 

그리고 자바 스크립트에서

관련 문제