English 中文(简体)
通用图像的存档
原标题:Rotating images generically

因此,迄今为止,这对我来说是一件好事,但我不想为页上的每一图像制定新的方法。 在被称作“Card”的方法中,我如何掌握“Card”的方法,因此,我可以在每一个图像纽扣上同样的方法。 是否有更好的办法这样做? 在被点击时,我想将图像90分解,在被点击时,再次将图像回旋。 问题在于,我只想使用一种能够转换任何形象的方法。

protected void Card_Click(object sender, ImageClickEventArgs e)
    {
        if (Card.CssClass == "rotate90Large")
        {
            Card.CssClass = "";
        }
        else
        {
            Card.CssClass = "rotate90Large";
        }
    }

iii

<style type="text/css"> 
    .rotate90Large{-ms-transform: rotate(90deg); margin-left:45px; } 

</style>

<asp:ImageButton ID="Card" ImageUrl="Graphics/image.jpg" runat="server" onclick="Card_Click"  />
最佳回答

锁定标语应当足够,而且你可以把所有图象都用在同一个点击活动中。 Card_Click

protected void Card_Click(object sender, ImageClickEventArgs e)
{
    ImageButton img = (ImageButton)sender;

    if (img.CssClass == "rotate90Large")
    {
        img.CssClass = "";
    }
    else
    {
        img.CssClass = "rotate90Large";
    }
}
问题回答

So write a function that takes an image as parameter, rotates it and returns it as the return value.... ?? Then call that function passing whichever image you want to rotate.

也许甚至把它当作一种延伸方法





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签