writing a function that calls a web user control in .cs file

Mar 15 2004 3:27 AM
I'm trying to write a function in a .cs file that when called by the index.aspx page it loads the corresponding user control. public static void loadUserControl() { Control controlHeader = null; Control controlNavigationMain = null; Control controlNavigationSub = null; Control controlCategory = null; String strControlDir= "user_controls/"; controlHeader = LoadControl(strControlDir + "header_home.ascx"); controlNavigationMain = LoadControl(strControlDir + "navigation_home_main.ascx"); controlNavigationSub = LoadControl(strControlDir + "navigation_home_sub.ascx"); controlCategory = LoadControl(strControlDir + "home_history.ascx"); // loads controls headerPlaceholder.Controls.Add(controlHeader); navigationMainPlaceholder.Controls.Add(controlNavigationMain); navigationSubPlaceholder.Controls.Add(controlNavigationSub); categoryPlaceholder.Controls.Add(controlCategory); } I'm not proficient at all with asp.net, so please ellaborate. If you could give me an example of what to do, I would REALLY appreciate it!

Answers (1)