如何从MVC格式的文本框中将古吉拉特文本插入数据库? [英] How to insert gujarati text to database from textbox in MVC form?

查看:63
本文介绍了如何从MVC格式的文本框中将古吉拉特文本插入数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个有古吉拉特语文本输入的表格并希望将其插入我的数据库,我添加的字体系列告诉我我正在输入古吉拉特语但是在插入期间它只是普通的旧英语所以如何在这里做是我到目前为止所尝试的:



我的型号:



i have a form which have gujarati text input and want to insert it into my database, the font-family that i added show me that i am typing gujarati but during insert it is just plain old english so how to do it here is what i have tried so far:

my model:

public class Insert_News
    {
        public int Newscategory { get; set; }
        public string NewsTitle { get; set; }
        public string NewsDescription { get; set; }
        public string ImageUrl { get; set; }
        public bool IsActive { get; set; }
    }







我的控制器:






my controller:

public ActionResult Index()
        {
            var query = (from c in db.NewsCategories where c.IsActive == true select new { Text = c.CategoryName, Value = c.NewsCategoryID }).ToList();
            ViewBag.category = query;
            return View();
        }
        [HttpPost]
        public ActionResult Index(Insert_News ns, HttpPostedFileBase ImageUrl)
        {
            var query = (from c in db.NewsCategories where c.IsActive == true select new { Text = c.CategoryName, Value = c.NewsCategoryID }).ToList();
            ViewBag.category = query;

            db.USP_Insert_NewsDetail(ns.Newscategory, ns.NewsTitle.ToString(), ns.NewsDescription.ToString(), ns.ImageUrl);
            string s1, s2, s3, s4;

 return View(ns);
        }





我的观点如下:





my View is as follows:

@using (Html.BeginForm("Index", "BhoomiNews", FormMethod.Post, new { @id = "insertnewsform", @enctype = "multipart/form-data", lang = "gu-IN" }))
{
    @Html.AntiForgeryToken()
    <div class="well-lg">
        <div class="form-horizontal" style="padding-removed5%;">
            @Html.ValidationSummary(true, "", new { @class = "text-danger" })
            <div class="form-group">
                <label class="forlabel">News Category</label><br /><br />
                <div class=" col-lg-10">
                    @*style="margin-left:-8.4%;"*@
                    @Html.DropDownList("NewsCategory", new SelectList(@ViewBag.category, "Value", "Text"), "Select Category", new { @class = "form-control forinput", id = "News_Category", @style = "width:102.7%;margin-top:-1.7%;" })
                    @Html.ValidationMessageFor(model => model.NewsTitle, "", new { @class = "text-danger" })
                </div>
            </div><br />

            <div class="form-group">
                <label class="forlabel">News Title</label><br /><br />
                <div class="col-lg-10">
                    @*style="margin-left:-5.7%;"*@
                           @Html.TextAreaFor(model => model.NewsTitle, new { @class = "form-control forinput", rows = "2", cols = "3", id = "txtnewstitless", @style = "margin-top:-1.7%;font-family:Vakil_01;" })
                           @Html.ValidationMessageFor(model => model.NewsTitle, "", new { @class = "text-danger" })></div>
            </div><br />

            <div class="form-group">
                <label class="forlabel">News Description</label><br /><br />
                <div class="col-lg-10">
                    @*style="margin-left:-10.5%;"*@
                    @Html.TextAreaFor(model => model.NewsDescription, new { @class = "form-control forinput", rows = "6", cols = "5", @style = "margin-top:-1.7%;font-family:Vakil_01;" })
                    @Html.ValidationMessageFor(model => model.NewsDescription, "", new { @class = "text-danger" })
                </div>
            </div>
            <br />
            <div class="form-group">
                <label class="forlabel">News Image</label><br /><br />
                <div class="col-lg-10">
                    @*style="margin-left:-7%;"*@
                    <input type="file" data-val="true" data-val-required="please select a file" class="form-control forinput" required name="ImageUrl" id="nwsimg" style="margin-top:-1.7%;" />
                    @Html.ValidationMessageFor(model => model.ImageUrl, "", new { @class = "text-danger" })
                </div>
            </div>
            <br />
            <div class="form-group">
                <div class="col-lg-2">
                    <button type="button" value="Add" class="btn btn-primary" id="btnaddnews" style=" width:100%;padding:10px 0;min-width:35%;">Add</button>
                    <div style="color:red;">@TempData["errormsg"]</div>
                </div>
            </div>
        </div>
    </div>
}





以下img显示问题:

请参考此图片:



我的视图:



http://s1.postimg.org/u5ef6y50v /myview.png [ ^ ]



我的控制器:



http://s30.postimg.org/9qb4g271t/mycontroller.png [ ^ ]

推荐答案

按照这个,

http://www.aspsnippets.com/Articles/Insert- Hindi-Marathi-Gujarati-Urdu-Persian-Arabic-Tamil-and-Telugu-languages-Text-characters-in-SQL-Server-using-C-and-VBNet.aspx [ ^ ]



-KR
Follow this,
http://www.aspsnippets.com/Articles/Insert-Hindi-Marathi-Gujarati-Urdu-Persian-Arabic-Tamil-and-Telugu-languages-Text-characters-in-SQL-Server-using-C-and-VBNet.aspx[^]

-KR


这篇关于如何从MVC格式的文本框中将古吉拉特文本插入数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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