Skip to content

Commit 9a06252

Browse files
Add files via upload
1 parent 2b251a8 commit 9a06252

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed

c/README.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
## How to work with WebForms Core in C (A hypothetical framework)
2+
3+
To use WebForms Core, first copy the WebForms class file in this directory to your project. Then create a new View file similar to the one below.
4+
5+
> Please note that this is a hypothetical framework. The codes below are close to pseudocode, but the WebForms class codes work correctly.
6+
7+
```c
8+
#include <stdio.h>
9+
#include <stdlib.h>
10+
11+
#include "backendframework.h" // A hypothetical framework
12+
13+
#include "WebForms.h"
14+
15+
int main() {
16+
// If is post method by submit form
17+
if (responseForm.hasKey("btn_SetBodyValue")) {
18+
char name[20] = responseForm.getValue("txt_Name");
19+
char backgroundColor[20] = responseForm.getValue("txt_BackgroundColor");
20+
int fontSize = atoi(responseForm.getValue("txt_BackgroundColor"));
21+
char message[28];
22+
23+
WebForms webForms;
24+
webForms.WebFormsData.count = 0;
25+
26+
WebForms_SetFontSize(&webForms, InputPlace_Tag("form"), fontSize);
27+
WebForms_SetBackgroundColor(&webForms, InputPlace_Tag("form"), backgroundColor);
28+
WebForms_SetDisabled(&webForms, InputPlace_Name("btn_SetBodyValue"), true);
29+
30+
WebForms_AddTag(&webForms, InputPlace_Tag("form"), "h3", "");
31+
WebForms_SetText(&webForms, InputPlace_Tag("h3"), (snprintf(message, sizeof(message), "Welcome %s", name), message));
32+
33+
printf("%s\n", WebForms_Response(&webForms));
34+
35+
WebForms_Clean(&webForms);
36+
37+
return 0;
38+
}
39+
40+
// If is get method
41+
printf("%s\n", backEndRender("view"));
42+
43+
return 0;
44+
}
45+
46+
##End
47+
48+
@@view
49+
<!DOCTYPE html>
50+
<html>
51+
<head>
52+
<title>Using WebForms Core</title>
53+
<script type="text/javascript" src="/script/web-forms.js"></script>
54+
</head>
55+
<body>
56+
<form method="post" action="/" >
57+
58+
<label for="txt_Name">Your Name</label>
59+
<input name="txt_Name" id="txt_Name" type="text" />
60+
<br>
61+
<label for="txt_FontSize">Set Font Size</label>
62+
<input name="txt_FontSize" id="txt_FontSize" type="number" value="16" min="10" max="36" />
63+
<br>
64+
<label for="txt_BackgroundColor">Set Background Color</label>
65+
<input name="txt_BackgroundColor" id="txt_BackgroundColor" type="text" />
66+
<br>
67+
<input name="btn_SetBodyValue" type="submit" value="Click to send data" />
68+
69+
</form>
70+
</body>
71+
</html>
72+
```
73+
74+
In the upper part of the View file, it is first checked whether the submit button has been clicked or not, if it has been clicked, an instance of the WebForms class is created, then the WebForms methods are called, and then the response method is printed on the screen, and other parts Views are not displayed.
75+
Please note that if the submit button is not clicked (initial request), the view page will be displayed completely for the requester.
76+
77+
As you can see, the WebFormsJS script has been added in the header section of the View file above.
78+
79+
The latest version of the WebFormsJS script is available through the link below.
80+
81+
https://github.com/elanatframework/Web_forms/blob/elanat_framework/web-forms.js

0 commit comments

Comments
 (0)