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

  • SEARCH
  • Home
  • 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 9243181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:45:10+00:00 2026-06-18T08:45:10+00:00

I work with Asp.net MVC4 (C#), I want to load data from controller to

  • 0

I work with Asp.net MVC4 (C#), I want to load data from controller to view.
from controller return an object in view, this object has an attribute of type TimeSpan (HH:DD:MM)
this is my function:

public JsonResult Buscar(string id){
        string Mensaje = "";
        Models.cSinDenuncias oDenuncia = new Models.cSinDenuncias();
        oDenuncia.sd_iddenuncia = id;
        var denuncia = Servicio.RecuperaDenuncia<Models.cSinDenuncias>(ref Mensaje, oDenuncia.getPk(), oDenuncia);
        return Json(denuncia);
    }

denuncia.sd_horadenuncia has for example this value 18:03:53 but I can’t load this value when show in the view this is the value [OBJECT OBJECT]
In the view (Html.TextBoxFor):

$('#HoraDen').val(data.sd_horadenuncia);

How I can recover the correct value? (HH:MM:SS) and not [OBJECT OBJECT]

Regards
Ricardo

  • 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-18T08:45:12+00:00Added an answer on June 18, 2026 at 8:45 am

    A TimeSpan is a complex type. This means that in your JSON it is serialized as such:

    {
        "sd_horadenuncia": {
            "Ticks": 3000000000,
            "Days": 0,
            "Hours": 0,
            "Milliseconds": 0,
            "Minutes": 5,
            "Seconds": 0,
            "TotalDays": 0.003472222222222222,
            "TotalHours": 0.08333333333333333,
            "TotalMilliseconds": 300000,
            "TotalMinutes": 5,
            "TotalSeconds": 300
        }
    }
    

    You are attempting to assign this complex object to a text field which obviously doesn’t make sense.

    You could use a view model on your controller action to preformat the value:

    public ActionResult Buscar(string id)
    {
        string Mensaje = "";
        Models.cSinDenuncias oDenuncia = new Models.cSinDenuncias();
        oDenuncia.sd_iddenuncia = id;
        var denuncia = Servicio.RecuperaDenuncia<Models.cSinDenuncias>(ref Mensaje, oDenuncia.getPk(), oDenuncia);
        return Json(new 
        { 
            formattedHoradenuncia = denuncia.sd_horadenuncia.ToString() 
        });
    }
    

    and then inside your view you could use the new property:

    $('#HoraDen').val(data.formattedHoradenuncia);
    

    Another possibility is to access individual properties of this complex object and format the value yourself:

    var hours = data.sd_horadenuncia.Hours;
    var minutes = data.sd_horadenuncia.Minutes;
    var seconds = data.sd_horadenuncia.Seconds;
    $('#HoraDen').val(hours + ':' + minutes + ':' + seconds);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having problem with getting ServiceStack [Authentication] attribute to work in ASP.Net MVC4 controller,
I work on Asp.Net VS08 C#. Clicking on Button want to show popup. popup
I am using the built-in SimpleMembership of the ASP.net MVC4 template and want to
I'm using asp.net mvc4, simplemembership and EF. actually i have this code to search
ASP.NET 4.5 has support for Asynchronous pages for web forms and MVC4 it seems.
I have an ASP.NET MVC4 website implementing a REST API, which I'm consuming from
I'm setting up my MVC4 app to use the built-in ASP.Net bundling (converting from
work on asp.net vs 05 C#.Master page header contain the bellow code <script type=text/javascript
Work on asp.net vs05. I have three type of value Like:IsDesign,IsPrinting,IsInstall they are bit
The ASP.NET validation does not seem to work inside ASP:FormView. Can someone let me

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.