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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:22:04+00:00 2026-05-31T22:22:04+00:00

i made an easy web user control by reading Scottgu articles BUT; my user

  • 0

i made an easy web user control by reading Scottgu articles

BUT; my user control return to me error:

ERROR

CountryDropDown.ascx:


<%@ Language="C#" Inherits="System.Web.Mvc.ViewUserControl<string>" %>
<%=ViewData["countries"] = new string[] { "France", "Germany", "US", "UK" })%>
<%var q = ViewData["countries"]; %>
<%= Html.DropDownList("",ViewData["countries"] as SelectList)%>

MY VİEW : <%= Html.EditorFor(c=>c.Country,”CountryDropDown”) %>

MODEL:

   public class Customer
{
    [Required(ErrorMessage="NameRequired")]
    [StringLength(50,ErrorMessage="Must be less than 50")]
    public string Name { get; set; }
    [Range(1,20,ErrorMessage="Invalid Age")]
    public int Age { get; set; }
    [Required(ErrorMessage="Email Required")]
    [RegularExpression(@"((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}")]
    public string Email { get; set; }
    [UIHint("CountryDropDown")]
    public string Country { get; set; }
}

how to make a ASCX in mvc with dropdownlist?

  • 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-05-31T22:22:06+00:00Added an answer on May 31, 2026 at 10:22 pm

    Using <%= tells ASP to print the following statement. You don’t want to be doing that in this case.

    <%@ Language="C#" Inherits="System.Web.Mvc.ViewUserControl<string>" %>
    <% 
        ViewData["countries"] = new string[] { "France", "Germany", "US", "UK" };
        var q = ViewData["countries"]; 
    %>
    <%= Html.DropDownList("",ViewData["countries"] as SelectList)%>
    

    Try that.

    Also, why do you assign q and not use it?

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

Sidebar

Related Questions

I made quite a few easy OSGi test projects in Eclipse RCP. My typical
I made a custom control that is basically a multiline TextBox that allows input,
We have 2 server clusters: the first is made up of typical web applications
I'm trying to learn Spring MVC 3.0 and I made a simple web to
I have a User control (because I use the same in other page, so
I have made up a simple set of web services (trying to make a
I've made two versions of a script that submits a (https) web page form
I've made a little game as an application for the web in silverlight using
Is there an easy way to examine the HTTP GET/POST/OPTIONS/HEAD etc requests being made
I need a free database for my web app made in Java EE 6.

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.