简体   繁体   English

将用户输入的文本原样存储在数据库C#中

[英]Store the text entered by the user as it is in the database C#

How to store the text entered by the user as it is in the database. 如何将用户输入的文本直接存储在数据库中。 Suppose if the user entered the text in proper case then the data should be stored in proper case in the database. 假设用户以适当的大小写输入了文本,则数据应以适当的大小写存储在数据库中。 If the user entered the text in upper case then the data should be stored in upper case and likewise. 如果用户以大写形式输入文本,则数据也应以大写形式存储。 I am changing the textbox style property according to the user setting in the database. 我正在根据数据库中的用户设置更改文本框样式属性。 If the user setting is in proper case then using style i am setting the textbox property to title case and proper case likewise. 如果用户设置是正确的话,那么我将使用样式将textbox属性设置为标题大小写和同样的大小写。 But when storing the data the text is entered in lower case irrespective of the case in which the user entered. 但是,在存储数据时,无论用户输入的是哪种情况,文本都以小写形式输入。

CompanyMasterClass cm = new CompanyMasterClass();
    cm.strcompany_code = Request.Cookies["userinfo"]["companycode"];
    ResultClass objress = cm.fn_GetNameNumberStyle();
    if (objress.bStatus)
    {
        eslist<CompanyMasterClass> OBJLISTS = objress.objData as eslist<CompanyMasterClass>;
        if (OBJLISTS.Count > 0)
        {
            ViewState["namestyle"] = OBJLISTS[0].strname_style.ToString();
            if (OBJLISTS[0].strname_style.ToString() == "PC")
            {
                //txtGroupName.Text = "";
                //txtGroupSname.Text = "";
            }
            if (OBJLISTS[0].strname_style.ToString() == "UC")
            {
                txtGroupName.Style.Add("text-transform", "uppercase");
                txtGroupSname.Style.Add("text-transform", "uppercase");
                lblGroupName.Style.Add("text-transform", "uppercase");
            }
            if (OBJLISTS[0].strname_style.ToString() == "UG")
            {
                // txtGroupName.Text = "";
                //txtGroupName.Text = "";
            }
        }
    }

Here I am setting the textbox style according to the property set in the database by the user. 在这里,我根据用户在数据库中设置的属性设置文本框样式。

How to store the text entered by the user with the case in the database? 如何将用户输入的带有案子的文本存储在数据库中?

Thanks, 谢谢,

The css style text-transform only displays the code in that way. CSS样式text-transform仅以这种方式显示代码。 It does nothing to the data entered by the user. 它对用户输入的数据不起作用。

If you want to store the data as per this formatting, you need to transform in on the server before inserting. 如果要按照此格式存储数据,则需要在插入之前在服务器上进行转换。

The browser will not do this for you. 浏览器将不会为您执行此操作。

You have to write some server code like: 您必须编写一些服务器代码,例如:

if (OBJLISTS[0].strname_style.ToString() == "UC")
{
    var myDbGroup = txtGroupName.Text.ToUpper();
}            

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM