Wrox Programmer Forums
|
ASP.NET 1.x and 2.0 Application Design Application design with ASP.NET 1.0, 1.1, and 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.x and 2.0 Application Design section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 15th, 2005, 02:40 PM
Authorized User
 
Join Date: Dec 2004
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.

El Hombre que tiene Amigos ha de mostrarse Amigo
__________________
El Hombre que tiene Amigos ha de mostrarse Amigo
 
Old March 17th, 2005, 04:25 PM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

I think you need to pass a more general object,an object WUC_CreDes.WebForm1 and WUC_CreDes.WebForm2 are derived from like Page,

public static bool Hay_PostBack(System.Web.UI.Page page,....){}

_____________
Mehdi.
software student.
 
Old March 17th, 2005, 08:04 PM
Authorized User
 
Join Date: Dec 2004
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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???


El Hombre que tiene Amigos ha de mostrarse Amigo
 
Old March 18th, 2005, 10:35 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

you declared frm in {} so it's just recognized within {},
Code:
WUC_CreDes.WebForm1 frm1;
WUC_CreDes.WebForm2 frm2;
if(parent1 is WUC_CreDes.WebForm1)
{
frm1 = (WUC_CreDes.WebForm1) parent1;
}
else
{
if(parent1 is WUC_CreDes.WebForm2)
{
frm2 = (WUC_CreDes.WebForm2) parent1;
}
}
_____________
Mehdi.
software student.
 
Old March 18th, 2005, 07:20 PM
Authorized User
 
Join Date: Dec 2004
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks you Mehdi:
But still I've an error.
My code is now:

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();
}
}

When I compile, in line: frm1.parent1.Example.Controls.Clear();
is sending me this error:
'WUC_CreDes.WebForm1' haven't a deffinition to 'parent1' Why?
I'll thank your help
A.L.

El Hombre que tiene Amigos ha de mostrarse Amigo
 
Old March 19th, 2005, 04:38 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

because : 'WUC_CreDes.WebForm1' haven't a deffinition to 'parent1'

try,
frm1.Example.Controls.Clear();

_____________
Mehdi.
software student.
 
Old March 22nd, 2005, 12:56 PM
Authorized User
 
Join Date: Dec 2004
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm sorry Mehdi, but still doing as you told me error persist.
Example is a place holder contening both in WebForm1 and in WebForm2.

I’ll thank your help.


El Hombre que tiene Amigos ha de mostrarse Amigo
 
Old March 22nd, 2005, 07:07 PM
Authorized User
 
Join Date: Dec 2004
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.


El Hombre que tiene Amigos ha de mostrarse Amigo





Similar Threads
Thread Thread Starter Forum Replies Last Post
Sending JSP form data to web server wambozi JSP Basics 1 July 7th, 2007 02:35 AM
Sending Outlook Task thru Web Application gadhiav ASP.NET 1.0 and 1.1 Professional 9 March 5th, 2007 10:36 AM
parameter sending to crystal report shahzadmalik Crystal Reports 0 March 2nd, 2007 02:30 AM
sending email from a form x_ray ASP.NET 1.0 and 1.1 Basics 5 February 22nd, 2006 02:58 PM
form parameter allang Apache Tomcat 1 August 10th, 2004 01:52 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.