Putting/passing/Retriving  a value From Aspx page into an ascx (user control) (URGENT)

Posted on 2005-04-11
Medium Priority
Last Modified: 2010-04-16

Hello everyone,

I have a question regarding Aspx and Ascx pages. Currently I have webform which has a usercontrol say "X.ascx"
On load of the web form(aspx) I have a particualr "UserId"  which has  been passed into this page from a differnt page , I would now like to pass this variable(its value actually) into the usercontrol which then retrives values depending on the UserID and pouplates drop downs and does some other stuff  .

It sounds fairly smiple ..but i need to get this pretty quickly .

Hoping that some one can help me out quickly,
Question by:Ashwin_shastry
  • 2

Accepted Solution

rajaloysious earned 500 total points
ID: 13752242
In the user control create a public property called UserId

private int _UserId; // class level variable

public int UserId
      get{return _UserId;}
      set{_UserId= value;}
XControl.UserId =<whatever>

LVL 21

Assisted Solution

Yurich earned 500 total points
ID: 13757261
you'll have to create manually a protected instance of your web control in your web form cs file, where you're loading, it since it's not added automatically:

protected X XControl;

Be very careful - even if you "create" it your selft, actually you don't...
1. protected - must be, otherwise will throw exception
2. X - that's your "X.ascx" file
3. XControl - must be exactly the name of the control your dropped on your form, won't work otherwise

then do as raja suggests...

LVL 21

Expert Comment

ID: 13953893
I would say that the question has been answered in full and the points should be split between rajaloysious and me.


Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month16 days, 22 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question