|
3 | 3 |
|
4 | 4 | WebForms Core technology was created by [Elanat](https://elanat.net). It is a two-way protocol between the WebForms class on the server side and the [web-forms.js](https://github.com/elanatframework/Web_forms/blob/elanat_framework/web-forms.js) library on the client side, where processing is done on the client side and the server sends Action Control commands to [WebFormsJS](https://github.com/elanatframework/Web_forms). |
5 | 5 |
|
6 | | -WebForms Core technology is fully supported on the core of the [CodeBehind Framework](https://github.com/elanatframework/Code_behind). |
| 6 | +By using WebForms Core technology, HTML tags are managed server-side, eliminating the need for front-end development. |
| 7 | + |
| 8 | +## WebForms Core Example |
| 9 | + |
| 10 | +To use WebForms Core technology, you need to get the [WebFormsJS](https://github.com/elanatframework/Web_forms/blob/elanat_framework/web-forms.js) library and add it to the head section of your HTML page. |
| 11 | + |
| 12 | +**HTML page** |
| 13 | +```diff |
| 14 | +<!DOCTYPE html> |
| 15 | +<html> |
| 16 | +<head> |
| 17 | + <title>WebForms Core Example</title> |
| 18 | ++ <script type="text/javascript" src="/script/web-forms.js"></script> |
| 19 | +</head> |
| 20 | +<body> |
| 21 | + <h1>Contact Us</h1> |
| 22 | + <form action="/contact" method="post"> |
| 23 | + Name:<input type="text" name="name" required><br> |
| 24 | + Email:<input type="email" name="email" required><br> |
| 25 | + Message:<br><textarea name="message" rows="4" cols="50" required></textarea><br> |
| 26 | + <input type="submit" name="button" value="Submit"> |
| 27 | + </form> |
| 28 | +</body> |
| 29 | +</html> |
| 30 | +``` |
| 31 | + |
| 32 | +On the server side, you also need to get the [WebForms class](https://github.com/elanatframework/Web_forms_classes) for the server programming language and implement it on your system. |
| 33 | + |
| 34 | +**C# example in CodeBehind framework*** |
| 35 | +```csharp |
| 36 | +using CodeBehind; |
| 37 | + |
| 38 | +public partial class ContactController : CodeBehindController |
| 39 | +{ |
| 40 | + public void PageLoad(HttpContext context) |
| 41 | + { |
| 42 | + if (context.Request.Form["button"].Has()) |
| 43 | + Button_Click(context); |
| 44 | + } |
| 45 | + |
| 46 | + private void Button_Click(HttpContext context) |
| 47 | + { |
| 48 | + // Code for add contact to database |
| 49 | + // ... |
| 50 | +
|
| 51 | + WebForms form = new WebForms(); |
| 52 | + |
| 53 | + string name = context.Request.Form["name"]; |
| 54 | + |
| 55 | + form.AddTag("<form>", "h3"); |
| 56 | + form.SetBackgroundColor("<h3>", "green"); |
| 57 | + form.SetText("<h3>", name + "! Your message was sent successfully."); |
| 58 | + form.Delete("<h3>"); |
| 59 | + form.AssignDelay(3); |
| 60 | + form.SetDisabled("(button)", true); |
| 61 | + |
| 62 | + Write(form.Response()); |
| 63 | + |
| 64 | + IgnoreViewAndModel = true; |
| 65 | + } |
| 66 | +} |
| 67 | +``` |
| 68 | + |
| 69 | +In this example, after clicking the button, first an instance of the WebForms class is created. Then a new h3 tag is created and the submit text is successfully added in it and shown to the user for 3 seconds and then removed. The submit button is also disabled and finally the response is sent to the client using the `Response` method. |
| 70 | + |
| 71 | +**What is sent from the client to the server?** |
| 72 | + |
| 73 | +In WebForms Core technology, data is sent as if it were an HTML page form submission. |
| 74 | +``` |
| 75 | +message=Please send your product price list to my email account.&[email protected]&name=Adriano&button=Submit |
| 76 | +``` |
| 77 | + |
| 78 | +**What does the server respond to the client?** |
| 79 | + |
| 80 | +The server response is also based on the INI pattern. |
| 81 | +``` |
| 82 | +[web-forms] |
| 83 | +sd(button)=1 |
| 84 | +nt<form>=h3 |
| 85 | +bc<h3>=green |
| 86 | +st<h3>=Adriano! Your message was sent successfully. |
| 87 | +:3)de<h3>=1 |
| 88 | +``` |
7 | 89 |
|
8 | 90 | You can see how WebForms Core works in the link below: |
9 | 91 |
|
|
0 commit comments