Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 15th, 2005, 12:24 PM   #1
see07
Programmer
 
Join Date: Oct 2004
Posts: 37
Rep Power: 0 see07 is on a distinguished road
Talking Sending a web form as parameter

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>
see07 is offline   Reply With Quote
Old Mar 17th, 2005, 5:53 PM   #2
see07
Programmer
 
Join Date: Oct 2004
Posts: 37
Rep Power: 0 see07 is on a distinguished road
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>
see07 is offline   Reply With Quote
Old Mar 22nd, 2005, 9:27 AM   #3
see07
Programmer
 
Join Date: Oct 2004
Posts: 37
Rep Power: 0 see07 is on a distinguished road
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>
see07 is offline   Reply With Quote
Old Mar 22nd, 2005, 4:42 PM   #4
see07
Programmer
 
Join Date: Oct 2004
Posts: 37
Rep Power: 0 see07 is on a distinguished road
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>
see07 is offline   Reply With Quote
Old Mar 24th, 2005, 9:25 PM   #5
new User(Kevin.Parkinson)
Programmer
 
new User(Kevin.Parkinson)'s Avatar
 
Join Date: Mar 2005
Location: Edmonton, Alberta, Canada
Posts: 37
Rep Power: 0 new User(Kevin.Parkinson) is on a distinguished road
Send a message via MSN to new User(Kevin.Parkinson)
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
new User(Kevin.Parkinson) is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:54 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC