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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:48:56+00:00 2026-06-09T19:48:56+00:00

I have this line in my view.aspx I am not using razor: <p style=color:Red>

  • 0

I have this line in my view.aspx I am not using razor:

 <p style="color:Red">
        <% Html.DropDownListFor(model => model.AllSundays, new SelectList(Model.AllSundays)); %>
  </p>

When I run my program and view source there is nothing there.
I am making use of the ViewModel in my action I have:

 var allSundaysInThisMonth = new SundaysInMonthViewModel
  {
    AllSundays = sundays.Select(x => new SelectListItem
    {
      Value = x.ToString("dd-MM-yyyy"),
      Text = x.ToString("dd-MM-yyyy"),
    })
  };

  var selectedSunday = new SundaysInMonthViewModel{
    SelectedSunday = thisMonthSundays.Where(x => x < now)
    .Last().ToString("dd-MM-yyyy")
  };

  return View(allSundaysInThisMonth);

thanks

  • 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-09T19:48:57+00:00Added an answer on June 9, 2026 at 7:48 pm

    You should use <%= and no comma at the end if you want to output something to the response, otherwise you are only executing server side code that never gets flushed to the response:

    <%= Html.DropDownListFor(
        model => model.AllSundays, 
        new SelectList(Model.AllSundays)
    ) %>
    

    Also AllSundays seems to already be an IEnumerable<SelectListItem> so you don’t need to feed that to a SelectList in the view:

    <%= Html.DropDownListFor(
        model => model.AllSundays, 
        Model.AllSundays
    ) %>
    

    Also (and this is extremely important), you should not use the same property as both the selected value and the available values. Currently you are using AllSundays twice. That’s absolutely wrong. The DropDownList helper expects as first argument a scalar property on your view model to hold the selected value and an IEnumerable<SelectListItem> property as second argument that will hold the selected values.

    So what you want is:

    <%= Html.DropDownListFor(
        model => model.SelectedSunday, 
        Model.AllSundays
    ) %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have this line of code in the view. <?php echo CHtml::activeTextField($model,'start_time'); ?>
I have this code in my javascript view model using Knockout. Everything works as
I have this line in my View <h1 > Reply to: @Model.dialogueEntity[index].DialogueSubject</h1> and I
I have this line in my razor view. @String.Format("{0:C}", @price) I want it to
I am using MVC. I have this line in my html: <div id=logo><a href=#><img
i have this line of code in my view using the Telerik Grid: columns.Bound(o
I want to draw this in my view to draw this line, I have
I have this line in my email.html.erb file: <%= link_to image_tag('video.png'), http://www.youtube.com/watch?v=QXhW34KzxL %> The
I have this line samtools view -h file | awk '$3==chr$a || /^@/' |
I have this line in my view file: - tweets = Twitter.user_timeline(@organization.twitter_name) The attr

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.