see07 Posted March 15, 2005 Posted March 15, 2005 Hello: From a web form I�m sending to execute a function contained into a class, code in web form is: bool que = WUC_CreDes.Class1.Hay_PostBack(this, w1,w1cx, w1ID, w2, w2cx, w2ID); In class code is: public static bool Hay_PostBack(WUC_CreDes.WebForm1 parent1, string w1, string w1cx, string w1ID, string w2, string w2cx, string w2ID) { string cual = ""; cual = HttpContext.Current.Session["par1"].ToString(); parent1.Example.Controls.Clear(); if(cual == w1) { Control control = parent1.Page.LoadControl(w1cx); control.ID = w1ID; parent1.Example.Controls.Add(control); } else { Control control = parent1.Page.LoadControl(w2cx); control.ID = w2ID; parent1.Example.Controls.Add(control); } return false; } As you can see, I�m sending to function container into class my WebForm1 to create in function WUC dynamically created. Thinking in a second web form, let us say, WebForm2, if within it I send to execute my function: bool que = WUC_CreDes.Class1.Hay_PostBack(this, w1,w1cx, w1ID, w2, w2cx, w2ID); How can I do to function Hay_PostBack, above mentioned work also for WebForm2 What I need to change because first parameter is WUC_CreDes.Web Form1 parent1? I�ll thank your answers. Greetings. A.L. Quote
see07 Posted March 18, 2005 Author Posted March 18, 2005 I'm coding: public static bool Hay_PostBack(System.Web.UI.Page parent1, string w1, string w1cx, string w1ID, string w2, string w2cx, string w2ID) { string fofoi = parent1.GetType().ToString(); if(fofoi == "ASP.WebForm1_aspx") { WUC_CreDes.WebForm1 frm = (WUC_CreDes.WebForm1) parent1; } else { if(fofoi == "ASP.WebForm2_aspx") { WUC_CreDes.WebForm2 frm = (WUC_CreDes.WebForm2) parent1; } } But frm is not being recogniz by system In what am I wrong??? Quote
see07 Posted March 22, 2005 Author Posted March 22, 2005 I�ve continued working on my code, it�s now thus: public static bool Hay_PostBack(System.Web.UI.Page parent1, string w1, string w1cx, string w1ID, string w2, string w2cx, string w2ID) { WUC_CreDes.WebForm1 frm1; WUC_CreDes.WebForm2 frm2; string fofoi = parent1.GetType().ToString(); if(fofoi == "ASP.WebForm1_aspx") { frm1 = (WUC_CreDes.WebForm1) parent1; frm1.parent1.Example.Controls.Clear(); } } Yet in last line: frm1.parent1.Example.Controls.Clear(); It�s giving me error: WUC_CreDes.WebForm1' doesn�t contains a definition to 'parent1'. Example is a place holder contening both in WebForm1 and in WebForm2. I�ll thank your help. A.L. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.