Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Passing Parameters to User Controls that are Dynamically Loaded in Placeholders

Reply
Thread Tools

Passing Parameters to User Controls that are Dynamically Loaded in Placeholders

 
 
Josh
Guest
Posts: n/a
 
      05-25-2004
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
 
Reply With Quote
 
 
 
 
Sam
Guest
Posts: n/a
 
      05-26-2004
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

http://www.velocityreviews.com/forums/(E-Mail Removed) (Josh) wrote in message news:<(E-Mail Removed). 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in running a basic code in python 3.3.0 that includes HTML file Satabdi Mukherjee Python 1 04-04-2013 07:48 PM
More passing parameters to dynamically loaded user controls voro.cibus@gmail.com ASP .Net 3 07-26-2005 11:37 PM
More passing parameters to dynamically loaded user controls JB McMichael ASP .Net 0 07-26-2005 10:21 PM
Passing Parameters to User Controls that are Dynamically Loaded in Placeholders Josh ASP .Net Web Controls 1 05-26-2004 06:41 AM
Passing Parameters to User Controls that are Dynamically Loaded in Placeholders Josh ASP .Net 1 05-26-2004 12:42 AM



Advertisments