1
 <% foreach (var item in Model) { %>

        <table width="100%" class="topicContainer">
           <tr>
             <td>  <%: Html.DisplayFor(modelItem => item.headerclob) %></td>
            </tr>
            <tr>
             <td><%: Html.ActionLink("ViewTopic", "ViewTopic","Forum" ,
               new { id=item.topicId },null) %></td>
            </tr>
        </table>

       <% } %>

I want of link ViewTopic item.headerclob should be displayed in hyperlink without using Razor.

I also want to apply css to it.

1 Answer 1

2

I think the below code should work

<%: Html.ActionLink("item.headerclob, "ViewTopic","Forum" ,
               new { id=item.topicId },null) %>

it use the following format

public static string ActionLink(this HtmlHelper htmlHelper, 
                                string linkText,
                                string actionName,
                                string controllerName,
                                object values, 
                                object htmlAttributes)

if you are using MVC 3 then the you can just use "item.topicId" instead of "id = item.topicId"

Edited yes it works but after removing semicolon from item.headerClob

    <%: Html.ActionLink(item.headerclob, "ViewTopic","Forum" ,
               new { id=item.topicId },null) %>

Edit add a class to action link then use your css file for setting necessary properties

<%: Html.ActionLink(item.headerclob, "ViewTopic","Forum" ,
                   new { id=item.topicId , @class = "YourClass"},null) %>

now you can apply css properties to the action link you set css properties to others

EDIT If you do not want to use razor, I could suggest you to build anchors by your self like following

<a href="<%=Url.Action("ViewTopic", "Forum",new { id=item.topicId})%>" class="YourClass"> item.headerclob </a>
Sign up to request clarification or add additional context in comments.

4 Comments

yes it is a slight mistake I just saw it. must have mistakenly typed the double quotation. please mark this as answer if this helps thank you
how to apply css to Html.ActionLink
I dontwant to use razor syntax
@prerna - that's not razor syntax, that's webform syntax

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.