c# - Referencing a non-existent user Control? -
i have created application searches directory , loads of usercontrols form , uses "getresult()" method grab answers form. did not oop style because still learning how utilize oop , going design oop can move onto next part lot easier if working objects. right have created "requestform" class , want requestform.result reach uc , call getresults() method. having difficult time getting though due lack of knowledge perhaps can point me in right direction.
formusercontrol - abstract class
namespace accessrequest { public abstract class formusercontrol : usercontrol { public abstract string name(); public abstract string getresults(); public abstract string emailusers(); } }
requestform - object class
namespace accessrequest { public class requestform { public string name { get; set; } public string controlid { get; set; } public string stepname { get; set; } public string filepath { get; set; } public string results { { //how pull usercontrol results control.getreults() within area? //i have since turned method. how access usercontrol loaded on asp page grab results? } set; } public string emails { get; set; } public int position { get; set; } public bool visible { get; set; } public requestform() { } /// <summary> /// formresults gathers needed information forms /// </summary> /// <param name="formname">name of form</param> /// <param name="formcontrolid">id of user control </param> /// <param name="wizardstepid">id of wizard step</param> /// <param name="formfilepath">file path of physical form</param> /// <param name="formresults">results form</param> /// <param name="formemails">other emails include</param> public requestform(string formname, string formcontrolid, string wizardstepid, int wizardstepposition, string formfilepath, string formresults, string formemails) { this.name = formname; this.controlid = formcontrolid; this.stepname = wizardstepid; this.position = wizardstepposition; this.filepath = formfilepath; this.results = formresults; this.emails = formemails; this.visible = false; } public void savelist(list<requestform> formlist) { // httpcontext.current.session["formlist"] = formlist; } } }
here loadforms() method put in oninit load of forms, have not implemented requestform piece believe should go builder object list.
private void loadforms() { string dotcolor = "black"; string formcolor = "#808080"; int loc = 3; foreach (listitem item in chklapplications.items) { string formpath = (string)item.value; wizardstepbase newstep = new wizardstep(); newstep.id = "wzstep" + item.text; newstep.title = string.format("<font color='{0}'> ¤</font> <font color='{1}'>{2} request</font>", dotcolor, formcolor, item.text); var form = loadcontrol(formpath); form.id = "uc" + item.text; newstep.controls.add(form); wzaccessrequest.wizardsteps.addat(loc, newstep); requestform.add(new requestform( item.text, //form name form.id.tostring(), //user control id newstep.id.tostring(), //wizardstep id loc, //wizardstep position item.value.tostring(), //file path null, //form results null //form emails )); loc++; } }
here set whether visible or not in side menu of wizard control. btw, know how can prevent creating table tags this? right growing large space inserting forms.
protected void sidebarlist_itemdatabound(object sender, datalistitemeventargs e) { if (e.item.itemtype == listitemtype.item || e.item.itemtype == listitemtype.alternatingitem) { if (!showwizardstep(e.item.dataitem)) { e.item.cssclass = "hidden"; } } }
thanks advise receive!! :d
ok, figured out. had method gather results form , spit them out on verification screen. manipulated code loads them directly object working with. objects full of dynamic information need controls , can manage them lot easier. here code in case else looking answer.
myclass
public class requestform { public string name { get; set; } public string controlid { get; set; } public string stepid { get; set; } public string filepath { get; set; } public string emails { get; set; } public string results { get; set; } public int position { get; set; } public bool visible { get; set; } /// <summary> /// formresults gathers needed information forms /// </summary> /// <param name="formname">name of form</param> /// <param name="formcontrolid">id of user control </param> /// <param name="wizardstepid">id of wizard step</param> /// <param name="formfilepath">file path of physical form</param> /// <param name="formresults">results form</param> /// <param name="formemails">other emails include</param> public requestform(string formname, string formcontrolid, string wizardstepid, int wizardstepposition, string formfilepath, string formemails,string formresults, bool formvisible = false) { this.name = formname; this.controlid = formcontrolid; this.stepid = wizardstepid; this.position = wizardstepposition; this.filepath = formfilepath; this.emails = formemails; this.results = formresults; this.visible = formvisible; } }
this list holds of controls
public list<requestform> requestform { { list<requestform> requestlist = new list<requestform>(); requestlist = (list<requestform>)session["requestforms"]; var v = session["requestforms"]; return v != null ? (list<requestform>)v : null; } set { session["requestforms"] = value; } }
this method use gather results , put them object.
private void gatherformsdata() { if (requestform != null) { foreach (requestform rform in requestform) { if (rform.visible) { wizardstepbase step = (wizardstep)wzaccessrequest.findcontrol(rform.stepid); formusercontrol form = (formusercontrol)step.findcontrol(rform.controlid); rform.results = string.format("{0}<br>email: {1}<br><br>", form.getresults(), form.emailcontact()); } } } }
hope helps someone.
Comments
Post a Comment