0

I started using asp.net MVC 4 and I don't quite understand how could I accomplish simple tasks like making a simple navigation menu for my website, I would like it to be just like the one here on stackoverflow where the images change on mouse over and also link to their corresponding pages.

what used to be a few minutes of work with HTML (in Dreamweaver for example) now takes much much more time and thought (at least for me).

Investigating about the 3 elements I've mentioned got me here:

  1. How to show an image- even that is not easy, I have looked everywhere for something that looks like an ideal solution but couldn't find any! even here on stackoverflow, some solutions are involving writing long lines of code in the name of "Helpers", and I could dig into it but there are so many different solutions, and I wouldn't know which one is right.. why can't there be just one standardized solution?

  2. How to link an image- also an issue, that i understand that I need to set the controller in the parameters list but again I ran into and issue that I might have found the solution for I just need to test it, I have read that I could have different methods inside of one controller and in this way I will not have to have one controller for each link. I will try that, better solutions are welcomed.

  3. How to swap an image on mouse over- also looks crazy for me, I have found one solution where there are long lines of code for this here: http://www.codeproject.com/Tips/329596/MVC-3-Helper-for-Hover-Images

I am kind of disappointed that just for putting up the logo image and linking it I spend days! I do have background in .net c# HTML+CSS etc'.. so I am asking myself (and you guys) why does it have to be so unclear and not friendly?

Come on.. what am I missing? is there any library of helpers everybody is using or something like that?

I am still in the process of learning MVC 4 and I know I'll get it but I would've expected accomplishing these kind of simple tasks a lot faster. also, in Microsoft examples, I have never found an example where they put a logo or a menu image, it is always plain text! so annoying and frustrating...

I will very much appreciate any help..

Thanks a lot!

Roy.

4

1 回答 1

0

从http://www.asp.net/mvc/mvc3开始,了解它的范式是什么以及 webform 和 mvc 系统之间的区别是什么。

基本上您需要了解母版页在 mvc 中是如何演变的,或者在 mvc 中母版页的替换是什么。

这是您想要实现的目标的线索。

现在,如果您想放置图像按钮,如果您将鼠标悬停并且颜色会改变,那么您需要执行以下步骤。

  1. 首先创建一个按钮,例如

Html.ActionLink("YourButtonName", "Index", null, new {@class="hoverButton" })

  1. 现在您需要在您的 css 文件中创建两个名为 hoverButton 的类,其中包含用于显示图像和 hoverButton:hover 显示图像的属性,当您将鼠标悬停在链接上时。跟下面一样。

hoverButton { margin-bottom: 10px; 宽度:160px;高度:160px;显示:块;background:transparent url('Button.png') center top no-repeat; }

.hoverButton:hover { 背景图片: url('hoverButton.png'); }

这样,当您将鼠标悬停在按钮上时,它将在 mvc 视图菜单项中显示不同的图像。

希望你理解这个概念,它会有所帮助。

于 2013-04-24T09:44:07.080 回答