c# - How to access user control properties if i load it programatically? -


i loaded user control (.ascx) programmatically like: loadcontrol("~/controls/mycontrol.ascx"). every thing ok until today when added 2 members control:

public stufftype stufftype { get; set; }  protected void page_load(object sender, eventargs e) {     switch (stufftype)     {         case cardtype.a:             fillgvstuff();             break;         case cardtype.b:             fillgvexstuff();             break;         default:             break;     }        } 

how can access stufftype?

i found kind of solution.

i think you'd this:

mycontrol ctrl = (mycontrol)loadcontrol("~/controls.mycontrol.ascx"); ctrl.stufftype = ...; // put control somehwere 

basically, when load it, assign variable , cast type , should have access methods , properties

you might want move page_load event page_prerender definetly setting property before page_load event occurs in control


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -