Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Pass Parameters to usercontrol View modes: 
User avatar
Member
Member
jothikumar018-gmail - 1/20/2011 4:47:38 AM
   
Pass Parameters to usercontrol
How to pass parameters to user control while using the usercontrol in page.

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 1/20/2011 7:37:02 AM
   
RE:Pass Parameters to usercontrol
Hello,

You can pass parameters to user controls in various ways. You can use a thread parameter, session parameter or cookie parameter:


// Setting the values

// set request stock helper (thread value)

CMS.GlobalHelper.RequestStockHelper.Add("partnercount", DropDownList1.SelectedValue.ToString());

// Set cookie:

CMS.GlobalHelper.CookieHelper.SetValue("partnercount", DropDownList1.SelectedValue.ToString(), DateTime.Now.AddDays(1));

// set session variable

HttpContext.Current.Session["partnercount"] = DropDownList1.SelectedValue.ToString();

// Getting the vaues

// Get cookie value:

string partnerCountCookie = CMS.GlobalHelper.CookieHelper.GetValue("partnercount");

// Get session value

string partnerCountSession = HttpContext.Current.Session["partnercount"].ToString();

// Get thread value

string partnerCountThread = CMS.GlobalHelper.RequestStockHelper.GetItem("partnercount").ToString();



Best regards,
Boris Pocatko

User avatar
Member
Member
jothikumar018-gmail - 1/27/2011 3:52:36 AM
   
RE:Pass Parameters to usercontrol
Thanks for your reply.

In my case I want to allow the user to specify some parameters while they are setting up the usercontrol by specifying the virtualpath of the usercontrol.

Is there any possibility to do so?

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 1/31/2011 9:02:12 AM
   
RE:Pass Parameters to usercontrol
Hello,

Could you please describe your requirement with an example in more detail?

Best regards,
Boris Pocatko

User avatar
Member
Member
Jeffrey H. - 1/31/2011 12:03:22 PM
   
RE:Pass Parameters to usercontrol
Yes, you could create a webpart with the parameters settable in the webpart properties, then the webpart dynamincally load said usercontrol using LoadControl method.

Seems overly complicated to me, may want to rethink what you are trying to do and be sure it is necessary.

Regards,

Jeff