Class Design: Multiple Typed Parameters?

  • Thread starter Thread starter clintonG
  • Start date Start date
C

clintonG

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
 
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.
 
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 said:
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]
- (e-mail address removed)

clintonG said:
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
 
clintonG said:
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.
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top