How can I write value of parameter from webpage to EMX?

I have a webserver, and a webpage can show me the current temperature values from EMX. The temperature values are loaded into a data.txt file for my web-server to serve. via AJAX-xmlhttprequest or jquery method this data.txt file could be updated every 5 seconds, then, corresponding with the update of my temperature-output web page.(see picture 1). the yellow field show me the current temperature values, the values are refreshed every 5 seconds.

Beside reading the parameter from EMX to webpage, I want to write parameter from webpage to EMX too. I want to define a parameter field(parameter table) on this webpage (see picture 1), if I click or double click the value of parameter, I can change the value of the parameter and the changed value can be transformed to EMX. Can you give me some suggestion, how can I realize my thinking?

Read about Post back, Html forms, etc… This is general http/web programming topic and there are tons of examples available.

If you would like to dynamically push data without causing a refresh, jQuery provides some API that can handle posting data.

@ James -

thank you for your suggestion, I am trying it.

@ Architect -

I have thought about your suggestion and I want to realize my frist step: writing somthing from forms to a text file.

After trying some times, I find a problem. If I do some thing about writing from forms to text file, I need use the php file.
but I don’t know how to retrieve the php file. It seems that I need a content type for php file

for example, as tutourial I tried the example link: ( )

I have written the codes for testing the example:

            using (HttpServer server = new HttpServer())
                server.AddEvent("/order.html", new HttpServer.EventCallback(Order));
                server.AddEvent("/process.php", new HttpServer.EventCallback(Process));
                while (true)
                    // Sleep for 500 milliseconds


        private static void Order(object sender, HttpServer.EventCallbackEventArgs e)
            e.Response = Resources.GetString(Resources.StringResources.order);
            e.ResponseContentType = "text/html";

        private static void Process(object sender, HttpServer.EventCallbackEventArgs e)
            e.BinaryResponse = Resources.GetBytes(Resources.BinaryResources.process);
             e.ResponseContentType=?????? // what is the Content-Type for php file??

The example can’t run successfilly without Content-Type for php file. How can I resolve the problem?

php is a server side technology. It needs to have support and PHP processor on the web server. Serving a php file back to a client as a content serves nothing.

@ andre.m -

Yes, I want to write something from forms to text file in a new webpage.

I tried some tutourial and found maybe I need the php file for getting or posting the forms.

It’s embarrassed for me…

I need find another tutourial for my thinking

I want to give a form a data in the webpage and after clicking the submit buttom the data can be saved in a txt file.

I read the data from the text file for my other thread subroutines in cs file of Visual Studio.

How can I avoid the php file to realize my thinking?

Similar to what you already have. In you form html page you provide a new action to a virtual page/url.

In the event handler for that virtual page/url you will need to check Request object to get to the Form fields with values and save them to your txt file.

Thank you for your help!!! I accept your suggestions about lerning http and html and javascript works

I are lerning them by doing.

I try again.

I have tried many times and read many examples, I find if I want to write something from form to a text file, I must use the php file. but as you told me, my webserve doesn’t support the php.

I feel despair,… where is the right way to resolve my thinking.

I still don’t understand how to write something from form to a text file avoid php. please some help…

PHP is an interpreter that runs on the “Server”. In your case, your server netmf code will be doing the same job.

Do you have a form that you can POST data with? That’s the first step.

If you then look at the data submitted in a form POST (debug it), you’ll see the data you want. You then just need to extract that and then do whatever you want to it in your app - including send it to a text file.

How can I provide a new action to a virtual page/url? Most online example is as follow, the action is ofen with a asp file or a php file.

<form name="input" action="????????" method="get">
Parameter: <input type="text" name="user">
<input type="submit" value="Submit">

How can I make a action to write the content of fom to a txt file after clicking the Submit buttom? can help you understand the form concepts in HTML

Thank you for your help !!! Brett, andre.m!!

I was tried and investigated some times, not successfull…ashamed… I have some codes as follow:

<!DOCTYPE html>

  <title>Form test</title>


<script type="text/javascript" language="javascript">
    function write_value_to_text_file(obj) {


<form action="javascript:write_value_to_text_file(document.getElementById('value1'));" method="get" target="_blank" id="myform">
  Parameter1: <input type="text" id="value1" name="P1"><input type="submit" value="Submit1"><br>
  Parameter2: <input type="text" id="value2" name="P2"><input type="submit" value="Submit2"><br>


I really don’t know how can I get the content of the 2 form and write them to a txt file. The most online examples is about writing to txt file with php.

As picture showed, if I give a form a value and click the buttom, the value will be written in txt file. then I want to access the txt file and get the value for my C# threadloop.

Your write_value_to_text_file is just a piece of js code that supposed to run on a client. You still need to make GET or POST request back to the server and pass the values from the input boxes.

As an exercise for you. Try to answer as fully as possible to this question: What is the difference between GET and POST http requests.

@ Architect -

I only know…

“GET” is simpler and faster than POST, and it can be for most cases.

“POST” is for sending large amount of data, user input(unknown charaters) and safer than GET.

No, you should be able to have a better answer. Think of the parts the generic HTTP request and response consist of in a raw form and then see the differences between GET and POST. Understanding of these concepts is crucial if you want to be successful in what you are doing.

I have read a lot of online examples, all examples about submitting form content to a text file need the help of php file. I have also tried any the AJAX and jquery examples, they also need the php file.

I can’t use the php file in my Webserver, I have tried all online examples, the php files of these examples don’t work in my webserver.

Can you give me a example about submitting form content to a text file without php file?

Ok, check this codeshare: