Hi,
I'm quite new to c# and OO programming, in brief...
I developed a 'classic' ASP / MSXML application, so I used VBsricpt for
the logic, xml files for storing informations and standard XSLT to
apply the due transformations and having the page displayed.
So no spaghetti-code at all, all the HTML elements are stored in the
XSLT files, the ASP pages has just to:
1 Retrieve the informations from the client thru hidden forms or
quesrystrings requests;
2 Store those values to variables;
3 Passing the values as parameters to the XSLT stylesheet;
Once passed in the XSLT stylesheet the values are stored in hidden
forms the client can later access thru javascript / dom operations.
This is the very common fashion for the XML / XSL community to develop
a client - server application, and suppose we have a parameter to
communicate both ways the route would be something like:
HTML page
================================================== ====
<html>
<head>
</head>
<body>
<form name="ciao" method="post">
<input name="paramId" type="hidden" value="">
<input type="button" onClick="document.ciao.paramId.value =
'newValue'">
</form>
</body>
</html>
ASP page
================================================== ====
dim paramId
'the variable is then initialized and if no form has been retrieved
'we assig zero, this way we can determine if is the first time we're
accessing
'to the page or if we are posting back. in .net this process is
automated
'in the prtty same way.
if paramId != "" then
paramId = request.form("paramId")
else
paramId = 0
end if
...
xml / xsl objects instantiation
...
'passing the parameter to the XSL stylesheet
xslProcessor.addParameter "paramId", paramId
XSLT page
================================================== ====
<xsl:stylesheet version="1.0">
<xsl:param name="paramId"/>
....
template stuff
....
<input type="hidden" name="paramId" value="{$paramId}"/>
</xsl:stylesheet>
Since the procedural approach has been very straightforward perform
such and other tasks, now I want to port my application in a dot.net
environment so I can perform even much compless tasks, at this point I
was wondering if ther could be any way to automate this process, I know
one of the most shouted isuues of asp.net is the use of web forms in a
similar fashion, but I need to keep my xslt files standard, so
basically avoiding " <asp:something> " elements in the stylesheets...
now, coming back to topic of my post:
If I have different parameters to communicate client - server, is there
any way I could collect them and later access them in som loop cycle?
Given the field name is always the same of the param name and the form
name, I would be able to do something like this:
//storing the variables in a struct or a class
public struct myVars
{
public int paramId;
public string paramName;
public int paramAge;
public int paramBirthday;
}
//once declared assigning their value
//I'm not sure at all about the syntax,
//it would be something like that anyway
public class assignValue
{
for each var in myVars
var.value = request[var.name];
next
}
//then i pass the params to the stylesheet in the same way...
//even less sure about the syntax!!
public class passParams
{
for each var in myVars
parms.AddParam(var.name, "", var.value);
next
}
So I basically need to store the parameters in field only once in my
program, then access them or as a group via a loop cycle or singularly
via a method or a property set (which seems to me the best thing to
do).
I tried to use indexers but later I can access the members oly via the
index reference, which is not the case, I'm considering other kinds of
collections but I'm not sure they can perform what I need them to.
I'm not even sure if it's possible to to accomplish similar task...
Any suggestion would ne appreciated!!!!
bye
marcello