Dynamic value assignment to some reference :

I am designing a Web server and I need to show the button Status( pressed/released ) on the client browser. I have used the following code for dynamically showing the HTML page. But now I want to put the HTML code into a reference. Can anyone suggest me how to pass the variables (ubs, sbs, dbs ) to the reference and use it as it was in the previous program…

 static string ButtonPage()
            // Determine the states of the three cobra buttons
            string ubs; if (upButton.Read() == false) ubs = "Pressed"; else ubs = "Released";
            string sbs; if (selectButton.Read() == false) sbs = "Pressed"; else sbs = "Released";
            string dbs; if (downButton.Read() == false) dbs = "Pressed"; else dbs = "Released";

            // Build the web page
            string s = "<html>\n";                                      // First the page type
            s += "<head><title>Fez Cobra Test Page</title></head>\n";   // now the page header
            s += "<body>\n";                                            // start the body        
            s += "<p>Up Button State = <i>" + ubs + "</i></p>";         // Up button, state in italics
            s += "<p>Select Button State = <i>" + sbs + "</i></p>";     // Select button, state in italics
            s += "<p>Down Button State = <i>" + dbs + "</i></p>";       // Down button, state in italics
            s += "</body>";                                             // close the body section
            s += "</html>";                                             // close the page type
            return s;

Thanx & Regards,

Not sure what this means[quote] Can anyone suggest me how to pass the variables (ubs, sbs, dbs ) to the reference[/quote]

The following code would allow you to pass the string references and change them in the routine.

static string ButtonPage( ref string ubs, ref string sbs, ref string dbs )

If all you want is to pass the string values:

static string ButtonPage( string ubs, string sbs, string dbs )

actually I don’t want to keep the html code in the c# page instead I want to put it in the references and call it like…

s = Resources.GetString(Resources.StringResources.html file); 

in that case I need to use the values of the variables(mentioned in the post above) in the HTML page. And my question is can I send those values from the C# page to that html page dynamically…

You could make a simple ASP parser.

Put the html in a resource file, then as you stream it out, fill some token variables with actual values.

E.g. Hello <%name%>

So look for <%, extract the variable name, look up the value and stream it out.

Because there is no reflection in NETMF you will need to use a Switch statement or perhaps a lookup dictionary.

This is more efficient than reading the entire file into memory first. Maybe you could read a block, parse, stream and repeat.