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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:33:14+00:00 2026-05-19T02:33:14+00:00

protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { loadCountries(); loadRegions(); loadCities(); }

  • 0
protected void Page_Load(object sender, EventArgs e)
{
    if (!Page.IsPostBack)
    {
        loadCountries();
        loadRegions();
        loadCities();
    }
}

private void loadCountries()
{
    Country country = new Country();
    ddlCountry.DataSource = country.GetDataTable();
    ddlCountry.DataTextField = "countryName";
    ddlCountry.DataValueField = "countryID";
    ddlCountry.DataBind();
}

private void loadRegions()
{
    Region region = new Region();
    ddlRegion.DataSource = region.GetRegionID(ddlCountry.SelectedValue);
    ddlRegion.DataTextField = "regionName";
    ddlRegion.DataValueField = "regionID";
    ddlRegion.DataBind();

}

private void loadCities()
{
    City city = new City();
    ddlCity.DataSource = city.GetCityID(ddlRegion.SelectedValue);
    ddlCity.DataTextField = "cityName";
    ddlCity.DataValueField = "cityID";
    ddlCity.DataBind();
}

protected void ddlCountry_SelectedIndexChanged(object sender, EventArgs e)
{
    loadRegions();
    if (ddlRegion.SelectedItem.Text == "No Province")
    {
        ddlRegion.Enabled = false;
        loadCities();
    }
    else
    {
        ddlRegion.Enabled = true;
        loadCities();
    }
}

The code is back-end of Default.aspx (Presentation layer)

Any business logic related to Country is put into Country class, same rules applied to Region and City.

Is this snippet design OK? In other words, does it meet the presentation layer standard design? How can i improve this snippet design (if possible)?

I’m new to this, i try to make sure i take it slowly but surely.

  • 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-19T02:33:15+00:00Added an answer on May 19, 2026 at 2:33 am

    I think the naming conventions need some work. Think carefully about the names of your classes and methods.

    For example (class name):

    You have a class called Country which suggests it represents a country. But, I don’t think it does. It looks like it’s responsible for creating a datatable of countries.

    and another example (method name):

    You have a method called Region.GetRegionID(). It looks (but I’m not completely sure) as if this gets a Region based on a RegionId so i’d prefer GetByRegionId. The same critism of the name of the class applies.

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

Sidebar

Related Questions

Then: protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { CheckBoxList1.Items.Add(new ListItem(item1)); CheckBoxList1.Items.Add(new
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { Response.Cache.SetCacheability(HttpCacheability.NoCache ); Response.Cache.SetAllowResponseInBrowserHistory(false); }
Shouldn't PostBack be checked before Session protected void Page_Load(object sender, EventArgs e) { if
This works just fine: protected void txtTest_Load(object sender, EventArgs e) { if (sender is
Consider the following code: Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
I am sorting a GridView bind to a ananymous type. protected void GridView1_Sorting(object sender,
Please take a look at this: protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { int
Is it recommended to check the Page.IsPostBack in a user control Page_Load Event like
typedef void (FunctionSet::* Function)(); class MyFunctionSet : public FunctionSet { protected: void addFunctions() {
In my code behind I wire up my events like so: protected override void

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.