如何存储和检索用户输入的答案(编程) [英] how to store and retrive user's answer(programming) like they input

查看:85
本文介绍了如何存储和检索用户输入的答案(编程)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在用户在文本框/注释框中编写的视图中存储和检索编程代码。(就像在本网站中,代码显示在解决方案页面中)。

I want to store and retrieve programming code in a view that is written by users in a text box/comment box like they write.(like in this website, the codes are displayed in the solution page).

推荐答案

只有很少的事情要知道:

There is only few things to know:


  1. 什么是编程代码,源代码通过网络浏览器显示?

    这是一个文本,使用html标签格式化的文本。它可以被称为:编程代码= html代码
  2. 应该使用什么数据类型来存储HTML代码?

    Varchar数据类型应该足够了,除非你想存储非英语语言使用的特殊字符。在这种情况下,您应该使用Nvarchar。请参阅:数据类型(T-SQL) [ ^ ]
  3. 我应该编码和解码html文本?

    是的,您需要对html文本进行编码/解码:


  1. What is "programming code", "source code" displayed via web browser?
    It is a text, text formatted by using html tags. It could be called: programming code = html code.
  2. What data type should be used to store html code?
    Varchar data type should be enough, unless you want to store special characters used by other than English languages. In this case you should use Nvarchar. See: Data Types (T-SQL)[^]
  3. Should i encode and decode html text?
    Yes, you need to encode/decode html text:
//before you save data in Sql server database, encode it
string htmlcode = WebUtility.HtmlEncode(text_with_html_tags);

//if you want to display content on Web page, decode it
string text_with_html_tags = WebUtility.HtmlDecode(htmlcode);





如果我没错,可以在CodeProject网站上找到以前版本的CP板的源代码。使用窗口右上角的SearchBox。



If i'm not wrong, here on CodeProject site, you can find source code of previous version of CP board. Use "SearchBox" on the right-top corner of window.


这篇关于如何存储和检索用户输入的答案(编程)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆