471,354 Members | 1,411 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,354 software developers and data experts.

Class Design: Multiple Typed Parameters?

I'm using the 2.0 Wizard control which includes three basic control types in
its various steps; TextBox, DropDownList, and CheckBoxList controls. I'd
like to pass the results of the Wizard to a class but I don't understand how
to type the class or pass the arguments to the parameters of the class when
different types are involved.

All I think I need is confirmation and a signature typing the class
definition. While I'm off to read about generics to determine if this is how
I achieve my goal what would your comments be?

<%= Clinton Gallagher
Jan 17 '06 #1
4 1186
Clinton,

It's a little vague what you are trying to do. You are using the wizard
control, but are you looking for a general solution or are you looking to
return specific parameters?

My first guess is to return a key/value pair, which has the name of the
control, as well as the control itself. You can return a type of Control,
which all three derive from.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.com> wrote in message
news:OD**************@TK2MSFTNGP11.phx.gbl...
I'm using the 2.0 Wizard control which includes three basic control types
in its various steps; TextBox, DropDownList, and CheckBoxList controls.
I'd like to pass the results of the Wizard to a class but I don't
understand how to type the class or pass the arguments to the parameters
of the class when different types are involved.

All I think I need is confirmation and a signature typing the class
definition. While I'm off to read about generics to determine if this is
how I achieve my goal what would your comments be?

<%= Clinton Gallagher

Jan 17 '06 #2
protected void Wizard1_FinishButtonClick( ... )
{

// Initialize a class named XmlFileWriter
XmlFileWriter wrt = XmlFileWriter( );

// Pass arguments in the method call
wrt.saveXmlFile( textBox1, textBox2)

} // click event

// Instance of the XmlFileWriter class
public class XmlFileWriter
{
// Method is strongly typed
public string saveXmlFile( string textBox1, string textBox2 )
{
...
}

} // class

Okay?
The arguments passed in the method call are of type string because they are
text entered into the TextBox controls. The parameters of the saveXmlFile
method are of type string and the return type of the saveXmlFile method is
of type string.

Now here's the problem.
I also need to pass a CheckBoxList with textBox1 and textBox2 in the method
call but I don't know how to type the parameter in the signature of the
method and I don't even think passing the CheckBoxList is even permitted in
this context...

// Pass arguments in the method call
wrt.saveXmlFile( textBox1, textBox2, checkBoxList1)

// What is the method signature and the modifer for checkBox1?
public string saveXmlFile( string textBox1, string textBox2, ... checkBox1)

The saveXmlFile method uses an instance of an XmlFileWriter to write an XML
file and I need the value of the ListItems from checkBoxList1 to populate
the XML file with data.

Clear as mud? :-)

<%= Clinton Gallagher



"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2***************@TK2MSFTNGP15.phx.gbl...
Clinton,

It's a little vague what you are trying to do. You are using the
wizard control, but are you looking for a general solution or are you
looking to return specific parameters?

My first guess is to return a key/value pair, which has the name of the
control, as well as the control itself. You can return a type of Control,
which all three derive from.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.com> wrote in message
news:OD**************@TK2MSFTNGP11.phx.gbl...
I'm using the 2.0 Wizard control which includes three basic control types
in its various steps; TextBox, DropDownList, and CheckBoxList controls.
I'd like to pass the results of the Wizard to a class but I don't
understand how to type the class or pass the arguments to the parameters
of the class when different types are involved.

All I think I need is confirmation and a signature typing the class
definition. While I'm off to read about generics to determine if this is
how I achieve my goal what would your comments be?

<%= Clinton Gallagher


Jan 17 '06 #3
clintonG <cs*********@REMOVETHISTEXTmetromilwaukee.com> wrote:
Now here's the problem.
I also need to pass a CheckBoxList with textBox1 and textBox2 in the method
call but I don't know how to type the parameter in the signature of the
method and I don't even think passing the CheckBoxList is even permitted in
this context...
It's fine.
// Pass arguments in the method call
wrt.saveXmlFile( textBox1, textBox2, checkBoxList1)

// What is the method signature and the modifer for checkBox1?
public string saveXmlFile( string textBox1, string textBox2, ... checkBox1)
public string SaveXmlFile (string textBox1,
string textBox2,
CheckBoxList cbList)

Control classes are classes just like any other.
The saveXmlFile method uses an instance of an XmlFileWriter to write an XML
file and I need the value of the ListItems from checkBoxList1 to populate
the XML file with data.


You might want to consider passing in the values you want to write
rather than the CheckBoxList itself then, eg as a list of strings.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jan 17 '06 #4
<snip />

You might want to consider passing in the values you want to write
rather than the CheckBoxList itself then, eg as a list of strings.


I've taken your advice about passing the values. Thanks for your
support Jon.

<%= Clinton Gallagher
Jan 18 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

18 posts views Thread by Bradley | last post: by
20 posts views Thread by Scott M. | last post: by
21 posts views Thread by phpCodeHead | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.