Re: Reading a public variable from a web user control
- From: "Axel Dahmen" <KeenToKnow@xxxxxxxxxxxxxxxxx>
- Date: Mon, 16 Jan 2006 01:07:15 +0100
You need to move the following line to Page_Init():
> Control ctl1 = LoadControl("../controls/ctl1.ascx");
This way ASP.NET can fill that control with its PostBack value before
Page_Load() is called.
HTH,
Axel Dahmen
------------
"Vi" <Vi@xxxxxxxxxxxxxxxxxxxxxxxxx> schrieb im Newsbeitrag
news:8DCC4D29-3D12-4A01-AD91-F9DB847C6EBB@xxxxxxxxxxxxxxxx
> Hi,
> I created a web user control that works fine to display some data. Now I
> want to be able to read a public int variable from the control, but I
always
> get the value I'm innitilizing the variable with. Meaning I can't get the
> value that is set within the control.
> Here's the code I use:
> Control ctl1 = LoadControl("../controls/ctl1.ascx");
> ((MyNamespace.ControlName)ctl1).id = myInitID;
> iVarFromTheControl = ((MyNamespace.ControlName)ctl1).iVarFromTheControl;
> PlaceHolder1.Controls.Add(ctl1);
>
> This code is in Page_Load and debugging step-by-step I saw that the
> control's code is executed only after Page_Load has finished executing. So
I
> guess that's the problem, but I'm not sure how to solve it.
>
> Thanks.
>
.
- Prev by Date: Re: Website on a website.
- Next by Date: Re: Enabling/diusabling child controls
- Previous by thread: Re: strange question about DropDownList
- Next by thread: Re: Enabling/diusabling child controls
- Index(es):
Relevant Pages
|
Loading