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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:57:54+00:00 2026-06-09T04:57:54+00:00

I am working on an ASP .net project. I am trying to load a

  • 0

I am working on an ASP .net project. I am trying to load a user control in a Control object with the following code and i am trying to pass a parameter to that control. On the debugging mode I get an error on that line saying that The file '/mainScreen.ascx?matchID=2' does not exist.. If I remove the parameters then it works ok. Can anyone help me to pass those parameters? Any suggestions?

    Control CurrentControl = Page.LoadControl("mainScreen.ascx?matchID=2");
  • 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-09T04:57:56+00:00Added an answer on June 9, 2026 at 4:57 am

    You cannot pass the parameter via query-string notation because user controls are simply “a building blocks” referenced by virtual path.

    What you can do instead is to make a public property and assign the value to it once the control is loaded:

    public class mainScreen: UserControl
    {
        public int matchID { get; set; }
    }
    
    // ...
    
    mainScreen CurrentControl = (mainScreen)Page.LoadControl("mainScreen.ascx");
    CurrentControl.matchID = 2;
    

    You can now use the matchID inside your user control like the following:

    private void Page_Load(object sender, EventArgs e)
    {
        int id = this.matchID;
    
        // Load control data
    }
    

    Note that the the control is participating in the page life cycle only if it’s added into the page tree:

    Page.Controls.Add(CurrentControl); // Now the "Page_Load" method will be called
    

    Hope this helps.

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

Sidebar

Related Questions

I'm trying to find any code working in the ASP.NET project that would be
Working on an ASP.NET Project (not Web Site) and trying to Start without Debugging
I'm currently working on a ASP.Net 3.5 project and trying to implement session timeout
I am working on a school project that uses ASP.NET. I found this TextEditor
I've inherited a asp.net project and I'm finding that the code behind pages contain
I am working on an ASP.NET MVC project and I am trying to get
Im currently trying to refactor a project(asp.net mvc) that doesnt have any separation at
I've been working on an ASP.net MVC project that uses checkbox HTML Helpers in
I am currently working on a c# asp.net web project and I am trying
So i am working on ASP.NET project. I was trying to debug a wierd

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.