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
Post a Comment