Hi Joy,
Sorry it took so long to get back to you on this subject. I haven't tried
your idea yet, but it is an interesting idea for some other part of the
project possibly. I don't think this will work directly for this particular
problem. Here is in some more detail of what I need to do, now that I have
clearance to do so. On this particular page, there is a wizard control that
has 7 different steps to it. In step 1, there are the following controls:
1. ContractHeaderDirectionsLabel - Gives directions for step 1 of the
wizard.
2. ContractTitleTextBox - A textbox that will contain a title for the
created contract (entered by user).
3. ContractTitleTextBoxCounter - A custom built control that counts the
words/characters in the ContractTitleTextBox.
4. ContractTypeTextBox - A textbox that will contain the type of contract
being created (entered by user).
5. ContractTypeTextBoxCounter - A custom built control that counts the
words/characters in the ContractTypeTextBox.
6. HeaderActionButton - A LinkButton that when pressed, either initially
saves or saves changes in the contract header depending on the state of the
wizardStep.
The different "states" of the wizard step are:
1. Default- shows the wizard in a state where the contract header has never
been created before. The HeaderActionButton above would have a Text value of
"Save header" and a CommandName value of "FirstSave".
2. Preview mode where the HeaderActionButton above has the TextValue of
"Edit header" and a CommandName of "EditHeader". In this mode, the 2
textboxes above (ContractType and ContractTitle) would be changed to
readonly, the 2 TextBoxCounters would be made to be invisible and the
ContractHeaderDirectionsLabel would be changed to display a new set of
directions.
3. EditMode - This mode would have the HeaderActionButton Text value set to
"Save changes" and the CommandName set to "SaveChanges". In this mode the 2
TextBoxes are set back to their default mode with the current header
information inside the TextBoxes, the 2 TextBoxCounters would return to a
visible state and the HeaderDirectionsLabel would show another set of
directions for editMode.
This is why I need to know exactly how to handle this sort of stuff with
accessing controls from outside the page itself. Am I going to far by saying
that I need to have it done this way? I am looking at the plans for the 7
wizard steps, and it looks like putting all of that code inside the page
class would make the page very huge and bulky for what it does. It is
looking like the full 7 step wizard will take up around 300 or more code if
all in the page class. How should I continue with the controls access issue?
"Joy" <Jo*@discussions.microsoft.comwrote in message
news:06**********************************@microsof t.com...
Hi Andy,
I would have been better equipped to help you, had i been aware of your
business scenario.
However, if you have more than 3 control's value to be passed as parameter
then i would suggest you to create a Parameter class. The following
example
will make the suggestion more clear for you:
Suppose you had to design an Customer registration page.
Suppose it had the following text fields:
1. Name
2. Age
3. City
4. Country
5. Language
6. Phone
7. Fax
You can write a Customer class that has the following private members and
should also be supported by getter/setter properties for each of the
private
members:
Public Class Customer
{
Private string strName ;
Private string strAge;
Private string strCity;
Private string strCountry;
Private string strLanguage;
Private string strPhone;
Private string strFax;
//Getter/Setter properties will follow here
public string Name
{
get
{
return strName ;
}
set
{
strName = value;
}
}
}
Then write the Data layer methods as such that they accept Customer class
object as parameters.
In the UI layer first make a Customer object and then initialise all its
properties with control's values and then make an object of the data layer
and call the DB method on this object thereby passing it the Customer
object
as parameter.
Please let me know if this worked for you.
regards,
Joy
"Andy B" wrote:
>I would have at least 8 or so UI controls that the class would need to
have
access to. Is this an unusual amount of parameters? I was possibly
thinking
of sending a collection of controls but not for sure if that will work or
not...
"Joy" <Jo*@discussions.microsoft.comwrote in message
news:A3**********************************@microso ft.com...
Hi Andy,
It is not a good practice to add some UI code in your data layer.
Normally
we write the Data Access layer to abstract the database related code
from
business and Presentation layer code.
Instead i would suggest you to write parameterized methods in your data
layer and make an object of this class in business/UI layer and then
call
these methods from there.
for example you can have a method that authenticates user so you can do
it
this way:
In data layer:
Public function AuthenticateUser(ByVal userName as string, ByVal
password
as
string) As boolean
'Make the Db call here and then return the result as true/false
depending
on
whether you got a row for the given username-password or not.
End function
Please let me know if it worked for you.else send me the code that you
are
writing.
regards,
Joy
"Andy B" wrote:
I have a class I am creating for data access. I need to access
controls
from
inside the class that are on a particular page. How do I do this? or
is
creating an instance of the page class and using FindControl the only
way
to
do it?