![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Oct 2004
Posts: 37
Rep Power: 0
![]() |
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.
__________________
<span style='color:red'>El Hombre que tiene Amigos, debe mostrarse Amigo...</span> |
|
|
|
|
|
#2 |
|
Programmer
Join Date: Oct 2004
Posts: 37
Rep Power: 0
![]() |
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 I'm wrong???
__________________
<span style='color:red'>El Hombre que tiene Amigos, debe mostrarse Amigo...</span> |
|
|
|
|
|
#3 |
|
Programmer
Join Date: Oct 2004
Posts: 37
Rep Power: 0
![]() |
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.
__________________
<span style='color:red'>El Hombre que tiene Amigos, debe mostrarse Amigo...</span> |
|
|
|
|
|
#4 |
|
Programmer
Join Date: Oct 2004
Posts: 37
Rep Power: 0
![]() |
Finally I found the solution:
To call function: bool que = WUC_CreDes.Class1.Hay_PostBack(this, w1,w1cx, w1ID, w2, w2cx, w2ID); The function: 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 cual = ""; cual = HttpContext.Current.Session["par1"].ToString(); string fofoi = parent1.GetType().ToString(); if(fofoi == "ASP.WebForm1_aspx") { frm1 = (WUC_CreDes.WebForm1) parent1; frm1.Example.Controls.Clear(); if(cual == w1) { Control control = frm1.Page.LoadControl(w1cx); control.ID = w1ID; frm1.Example.Controls.Add(control); } else { Control control = frm1.Page.LoadControl(w2cx); control.ID = w2ID; frm1.Example.Controls.Add(control); } } else { if(fofoi == "ASP.WebForm2_aspx") { frm2 = (WUC_CreDes.WebForm2) parent1; frm2.Example.Controls.Clear(); if(cual == w1) { Control control = frm2.Page.LoadControl(w1cx); control.ID = w1ID; frm2.Example.Controls.Add(control); } else { Control control = frm2.Page.LoadControl(w2cx); control.ID = w2ID; frm2.Example.Controls.Add(control); } } } return false; } Greetings. A.L.
__________________
<span style='color:red'>El Hombre que tiene Amigos, debe mostrarse Amigo...</span> |
|
|
|
|
|
#5 |
|
Programmer
|
see07:
With all due respect, I can't really understand your code! For example, what is w2cx? I would say that either some comments or renaming your variables would be in order. Kevin Parkinson |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|