Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Building Controls (http://www.velocityreviews.com/forums/f59-asp-net-building-controls.html)
-   -   Passing Parameters to User Controls that are Dynamically Loaded in Placeholders (http://www.velocityreviews.com/forums/t756743-passing-parameters-to-user-controls-that-are-dynamically-loaded-in-placeholders.html)

Josh 05-25-2004 11:43 PM

Passing Parameters to User Controls that are Dynamically Loaded in Placeholders
 
Hi Guys,

I have been having a big problem with trying to pass parameters into a
user control when the user control is dynamically loaded into a
placholder. I am developing in c#. I have get and set methods on the
user control "editButton.ascx" which work fine.

How do i pass parameter into the user controls "c1", "c2" ?

Here is a bit of my code that is calling the user control from the
aspx page.
public void setupTemplate(string PID)
{
//load control into a placeholder
UserControl c1 = (UserControl) LoadControl
System.Configuration.ConfigurationSettings.AppSett ings["virtualPath"]
+ "editButton.ascx");
UserControl c2 = (UserControl)
LoadControl(System.Configuration.ConfigurationSett ings.AppSettings["virtualPath"]
+ "editButton.ascx");

//PLACEHOLDER 1
PlaceHolder phPlaceHolder =
(PlaceHolder)this.FindControl("Form1").FindControl ("PlaceHolder1");
phPlaceHolder.Controls.Clear();
phPlaceHolder.Controls.Add(c1);
//PLACEHOLDER 2
PlaceHolder phPlaceHolder2 =
(PlaceHolder)this.FindControl("Form1").FindControl ("PlaceHolder2");
phPlaceHolder2.Controls.Clear();
phPlaceHolder2.Controls.Add(c2);
}

Any help would be greatly appreciated.

Thanks, Josh

Sam 05-26-2004 06:41 AM

Re: Passing Parameters to User Controls that are Dynamically Loaded in Placeholders
 
Hi,

Just cast it to the appropriate type, ie. instead of (UserControl) put
(editButton) or whatever you called the extended class in
editButton.ascx.

-Sam

josh@rb.com.au (Josh) wrote in message news:<f000fad9.0405251543.42bed269@posting.google. com>...
> Hi Guys,
>
> I have been having a big problem with trying to pass parameters into a
> user control when the user control is dynamically loaded into a
> placholder. I am developing in c#. I have get and set methods on the
> user control "editButton.ascx" which work fine.
>
> How do i pass parameter into the user controls "c1", "c2" ?
>
> Here is a bit of my code that is calling the user control from the
> aspx page.
> public void setupTemplate(string PID)
> {
> //load control into a placeholder
> UserControl c1 = (UserControl) LoadControl
> System.Configuration.ConfigurationSettings.AppSett ings["virtualPath"]
> + "editButton.ascx");
> UserControl c2 = (UserControl)
> LoadControl(System.Configuration.ConfigurationSett ings.AppSettings["virtualPath"]
> + "editButton.ascx");
>
> //PLACEHOLDER 1
> PlaceHolder phPlaceHolder =
> (PlaceHolder)this.FindControl("Form1").FindControl ("PlaceHolder1");
> phPlaceHolder.Controls.Clear();
> phPlaceHolder.Controls.Add(c1);
> //PLACEHOLDER 2
> PlaceHolder phPlaceHolder2 =
> (PlaceHolder)this.FindControl("Form1").FindControl ("PlaceHolder2");
> phPlaceHolder2.Controls.Clear();
> phPlaceHolder2.Controls.Add(c2);
> }
>
> Any help would be greatly appreciated.
>
> Thanks, Josh



All times are GMT. The time now is 12:24 PM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57