简体   繁体   中英

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. 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. 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();
}            

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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