0

Im having a problem with going to the correct link. When im trying to go to index view in template folder it goes to index view in admin folder instead and i cant understand why when the code says it should look for this view in this specific folder:

<fieldset>

<legend>SiteConfig</legend>
<p>Create new or edit Customers, Projects etc:   
    @Html.ActionLink("Create", "Add", "Admin", string.Empty) |
    @Html.ActionLink("Edit", "AddEdit", "Admin", string.Empty)
</p>
<p>Create new or edit Users:
    @Html.ActionLink("Create", "Add", "Admin", string.Empty) |
    @Html.ActionLink("Edit", "AddEdit", "Admin", string.Empty)
</p>
<p>Upload or change Logo:
    @Html.ActionLink("Upload", "Add", "Admin", string.Empty) |
    @Html.ActionLink("Change", "AddEdit", "Admin", string.Empty)
</p>
<p>Upload or change Template:
    @Html.ActionLink("Upload", "Index", "Template", string.Empty) |
    @Html.ActionLink("Change", "AddEdit", "Admin", string.Empty)
</p>
</fieldset>
user2043267
  • 71
  • 1
  • 12

2 Answers2

1

You are most probably calling the wrong overload. What is that string.Empty for?

Is Admin a controller and if so then you can just simple do a

@Html.ActionLink("Create", "Add", "Admin") 

Are you trying to add some html styling to your links, then do this

@Html.ActionLink("Create", "Add", "Admin", new { @class = "some-class-name"} ) 

Are you trying to pass some parameters

@Html.ActionLink("Create", "Add", "Admin", new { @id = 5}, null ) 
von v.
  • 16,868
  • 4
  • 60
  • 84
  • dont know what why my colleges used string.empty for, but it worked using a normal instead of actionlink – user2043267 May 06 '13 at 09:07
  • It will definitely work with an href, I think no doubt about it as long as the url is correct of course. So with your question, if the `Admin` is a controller and `Add` is a method then just remove the `string.Empty` - it does not server any purpose. If your colleague asked you why you removed it then ask him why he added it in the first place - then everything can get cleared ;) – von v. May 06 '13 at 09:23
0

Your question isn't completely clear, but for the links you provided, always Admin is set as a controller name (third parameter). So in all of your links, the Add or AddEdit method will be called in the Admin controller, and therefore always the Add or AddEdit template will be used from the Views/Admin folder.

Andras Toth
  • 576
  • 4
  • 11
  • What Andras said was practically correct the syntax for actionlink is {"string text","Action ","Controller",{Parameters}}. also when I am trying to go to a different controller passing a parameter, i always add a **null** parameter at the end. Just added info in case you encounter it also. – lou lising May 06 '13 at 09:00