NEWS

[C#] Hướng dẫn Encode and Decode HTML

[C#] Hướng dẫn Encode and Decode HTML
Đăng bởi: Thảo Meo - Lượt xem: 2456 12:15:03, 02/01/2023C#   In bài viết

Xin chào các bạn, bài viết hôm nay mình tiếp tục hướng dẫn cách giải mã và mã hóa (Encode và Decode HTML) trên lập trình C#, winform.

[C#] How to Encode and Decode HTML 

Trong cấu trúc của HTML có những ký tự như "<", ">" ... những ký tự trong thẻ tag của html.

Khi các bạn thấy khi chuyển dữ liệu đi hoặc lưu trữ HTML vào database thường chúng ta sẽ mã hóa các thẻ html này để lưu vào cơ sở dữ liệu.

Giao diện demo ứng dụng:

HTMLTHUMB

Video hướng dẫn step by step:

Source code C#:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace HTMLEncodeDecode
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnEncode_Click(object sender, EventArgs e)
        {
            var inputText = txtInput.Text.Trim();
            var htmlEncode = WebUtility.HtmlEncode(inputText);
            txtOutput.Text = htmlEncode;
        }

        private void btnDecode_Click(object sender, EventArgs e)
        {
            var inputText = txtInput.Text.Trim();
            var htmlDecode = WebUtility.HtmlDecode(inputText);
            txtOutput.Text = htmlDecode;
        }
    }
}

Thanks for watching!

DOWNLOAD SOURCE

THÔNG TIN TÁC GIẢ

BÀI VIẾT LIÊN QUAN

[C#] Hướng dẫn Encode and Decode HTML
Đăng bởi: Thảo Meo - Lượt xem: 2456 12:15:03, 02/01/2023C#   In bài viết

CÁC BÀI CÙNG CHỦ ĐỀ

Đọc tiếp
.