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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T13:41:09+00:00 2026-05-11T13:41:09+00:00

I have a piece of code in a User controls that normally should be

  • 0

I have a piece of code in a User controls that normally should be put in the Page_Load (initializes other components such DropDowns etc.) but I need this to happen before the Page_Load of the page that hosts this control.

I tried to put this in Page_Init:

protected void Page_Init(object sender, EventArgs e) {   if (!IsPostBack)   {     Methods.PopulateWhatList(cboWhatList0, cboWhatList1, fldWhat, Request['WhatId'], true);     Methods.PopulateWhereList(cboWhereList0, cboWhereList1, fldWhere, Request['WhereId'], true);     Methods.PopulateWhoList(cboWho, true, Request['WhoId']);     Methods.PopulateWhenList(cboWhen, true, Request['WhenId']);     Methods.PopulatePriceRangeList(cboPriceRange, true, Request['PriceRangeId']);         } } 

…but have experienced some problems. So where is the best place to but this type of code?

The problem I’m having (and might be unrelated) is that my:

 protected override void Render(HtmlTextWriter writer)  {    Methods.EnableValidationWhereList(cboWhereList1, this.Page);    Methods.EnableValidationWhatList(cboWhatList1, this.Page);    base.Render(writer);  } 

Isn’t called on certain postbacks? (When pressing a LinkButton?)

  • 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. 2026-05-11T13:41:09+00:00Added an answer on May 11, 2026 at 1:41 pm

    I’ll try a wild guess to what you’re trying to do and suggest a solution:

    In your Page_Init you’re populating the contents of various controls on the page. You’re dependent on URL parameters, hence the if(!IsPostBack) clause.

    After Page_Init, some of your controls are left in a disabled state, hence the need to enable them in your Render method.

    When doing a postback on the LinkButton, you don’t see your dropdowns populated on the next page rendering.

    What you’re experiencing is that disabled controls doesn’t get persisted to the ViewState. Since the SaveViewState is called before Render, you’re enabling the controls too late in the page lifecycle.

    If you instead move your Methods.EnableValidation... calls to a Pre_Render method on your page, control state will get persisted to the ViewState.

    After that fix, you should move your code in the Page_Init method to the Page_Load method, where it belongs. That way your controls data will have been loaded from the ViewState if you’re on a postback.

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

Sidebar

Ask A Question

Stats

  • Questions 251k
  • Answers 251k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer There are two kinds of token; I'm going to assume… May 13, 2026 at 9:30 am
  • Editorial Team
    Editorial Team added an answer While Page was the actual type, it was a class… May 13, 2026 at 9:30 am
  • Editorial Team
    Editorial Team added an answer Just use the group by operator: var query = from… May 13, 2026 at 9:30 am

Related Questions

Background I have an application written in native C++ over the course of several
I am writing a custom HTTP handler to provide an edit form for a
I imagine this is a pretty hard question to answer without sitting down and
(ASP.NET Web Application) I'd like to create a page which allows the user to

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.