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 8057705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:07:01+00:00 2026-06-05T09:07:01+00:00

This is bugging me and I don’t know what is going on. I created

  • 0

This is bugging me and I don’t know what is going on. I created a partial view to format a number properly.

The file _PermitNumber.cshtml is in /Views/Shared and contains:

@model System.Int32
@Html.Raw(Model.ToString("00-0000"))

On my main page I do:

@Html.DisplayFor(model => model.BuildingPermit.PermitId, "_PermitNumber")

model.BuildingPermit.PermitId is defined as an int.

My output is 120456 instead of the expected 12-0456.

What is going on?

  • 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-05T09:07:03+00:00Added an answer on June 5, 2026 at 9:07 am

    Why are you using a view for formatting your output? That seems like an unnecessary piece of complexity you are adding to your view. IMO a better location for this would be within a property of your view model:

    public string FormattedPermitNumber
    {
        get 
        {
             return PermitId.ToString("00-0000"));
        }
    }
    

    But to answer your question, if you were delete your partial view, you will see that your number is still displaying as 120456. In order to render your partial view you need to render the partial as follows:

    @{ Html.RenderPartial("_PermitNumber",  Model.BuildingPermit.PermitId); }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I don't have my Effective C++ with me and this is bugging me so
I'm getting this linker error. I know a way around it, but it's bugging
Ok, so this problem recently arose and I don't know why it is happening;
Usually I'm good with this type of thing, but this is bugging me. I
This has been bugging me for a good hour. I'm starting out with Telerik
This has been bugging me for more than two days now, so i thought
This Jquery problem has been bugging me for a while now. I developed a
This question has been bugging me for some time. I always picture launching my
This question has been bugging me for some time. I've already developed a couple
This is something that's been bugging me for many years: why most online services

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.