Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9066239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:41:34+00:00 2026-06-16T16:41:34+00:00

I am trying to learn MVC3 from Pro ASP.NET MVC3 Framework. But i am

  • 0

I am trying to learn MVC3 from Pro ASP.NET MVC3 Framework. But i am stuck at one place where we add custom Html Helper.

I did every thing mentioned in the book, but i am not able to add the custom Html helper.

Can somebody please help.

Thanks

List.cshtml

    @model SportsStore.WebUI.Models.ProductListViewModel          


@{    
    ViewBag.Titke = "Product";
}

<!DOCTYPE html>

<html>
<head>
    <title>List</title>
</head>
<body>
    <div>
        @foreach (var p in Model.Products)
        {
            <div class="item">
                @p.Name
                @p.Description
                <h4>@p.Price.ToString("c")</h4>                
            </div>
        }
        <div class="Pager">
        @Html.PageLinks(Model.pagingInfo, x => Url.Action("List", new {page = x}))
        </div>
    </div>    
</body>
</html>

PagingHelper.Cs

using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SportsStore.WebUI.Models;
using System.Text;

namespace SportsStore.WebUI.HtmlHelpers
{
    public static class PagingHelper
    {
        public static MvcHtmlString PageLinks(HtmlHelper helper, PagingInfo pagingInfo, Func<int, string> pageUrl)
        {
            StringBuilder linkString = new StringBuilder();
            for (int i = 1; i <= pagingInfo.TotalPages; i++)
            {
                TagBuilder tag = new TagBuilder("a");
                tag.MergeAttribute("href", pageUrl(i));
                tag.InnerHtml = i.ToString();
                if (i == pagingInfo.CurrentPage)
                {
                    tag.AddCssClass("selected");
                }
                linkString.Append(tag.ToString());
            }
            return MvcHtmlString.Create(linkString.ToString());

        }
    }
}

Web.Config

 <system.web.webPages.razor>
    <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <pages pageBaseType="System.Web.Mvc.WebViewPage">
      <namespaces>
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Routing" />
    <add namespace="SportsStore.WebUI.HtmlHelpers" /> 
      </namespaces>
    </pages>
  </system.web.webPages.razor>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T16:41:34+00:00Added an answer on June 16, 2026 at 4:41 pm

    You didn’t create an extension method.

    To make an extension method, you need to decorate the first parameter with the this keyword.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to learn ASP.Net MVC framework and I was wondering if there
I am trying to learn ASP.Net MVC from the asp.net website sample application MVCMovieApplication
I'm trying to learn ASP.NET MVC3 & jQuery, and I'm banging my head with
I'm trying to learn ASP.NET MVC 3 coming from a web forms background. I'm
I am trying to learn MVC using ASP.NET MVC3. Most of the tutorials I
I'm trying to create a custom membership system in ASP.NET MVC3 . I know
Trying to learn ASP MVC coming from Linux/LAMP background (in other words I'm a
I'm trying to learn ASP.NET MVC 3 with razor and so far getting the
I'm trying to learn MVC3 razor but I'm hitting a snag whenever I try
I am trying deploy my asp.net mvc3 application, here it is what i done

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.