将输入的字母数字数据转换为仅用于字母的大写字母 [英] to convert the input alphanumeric data to the uppercase only for alphabets

查看:108
本文介绍了将输入的字母数字数据转换为仅用于字母的大写字母的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将输入的字母数字数据从文本框转换为大写仅用于字母。





 受保护  void  Page_Load( object  sender,EventArgs e)

{
emp_mid = txtEmpmid.Text;

}









  protected   void  btnShowGraph_Click( object  sender,EventArgs e)
{




ViewState [ EmpDetails] = GetRptDetails(txtEmpmid.Text.ToString());
string details = ViewState [ EmpDetails ]的ToString();


string sourcepath = @ C:\Inetpub\wwwroot\Osource_local_Trial_Rushikesh\Code\PM\Roots\js\example1.js;

string destinationpath = @ C:\Inetpub\wwwroot\Osource_local_Trial_Rushikesh\Code\PM\Roots\GraphLoginData;

string filename = Session [ E_EMPNAME]。ToString()+ 。js;
string destFile = System.IO.Path.Combine(destinationpath,filename);

if (File.Exists(destFile))
{
File.Delete(destFile);

}
ReplaceTextInFile(sourcepath,destFile, REPLACE_CODE , 细节);


string JsFileName = js / + filename;
Literal script = new Literal();
script.Text = string .Format( @ < script src ={0}type =text / javascript>< / script>,JsFileName);
Page.Header.Controls.Add(script);

}

解决方案

尝试使用

 emp_mid = txtEmpmid.Text.ToUpper(); 





记住一件事,数值没有像上面或下面那样的类型,所以如果你在数值上应用ToUpper,它只返回相同的值...


看起来你需要使用方法 String.ToUpper(CultureInfo)

  string  myString = someString.ToUpper(System.Globalization.CultureInfo。 InvariantCulture); 



这样,即使使用了一些特定于文化的数字形式,也不会涉及它们。



-SA


尝试:

 < span class =code-keyword> string  details = GetRptDetails(txtEmpmid.Text).ToString()。ToUpper(); 
ViewState [ EmpDetails] = details;


I want to convert the input alphanumeric data which we take from the textbox to the uppercase only for alphabets.


protected void Page_Load(object sender, EventArgs e)

  {
      emp_mid= txtEmpmid.Text;

  }





protected void btnShowGraph_Click(object sender, EventArgs e)
{




    ViewState["EmpDetails"] = GetRptDetails(txtEmpmid.Text.ToString());
    string details = ViewState["EmpDetails"].ToString();


    string sourcepath = @"C:\Inetpub\wwwroot\Osource_local_Trial_Rushikesh\Code\PM\Roots\js\example1.js";

    string destinationpath = @"C:\Inetpub\wwwroot\Osource_local_Trial_Rushikesh\Code\PM\Roots\GraphLoginData";

    string filename = Session["E_EMPNAME"].ToString() + ".js";
    string destFile = System.IO.Path.Combine(destinationpath, filename);

    if (File.Exists(destFile))
    {
        File.Delete(destFile);

    }
    ReplaceTextInFile(sourcepath, destFile, "REPLACE_CODE", details);


    string JsFileName = "js/" + filename ;
    Literal script = new Literal();
    script.Text = string.Format(@"<script src=""{0}"" type=""text/javascript""></script>", JsFileName);
    Page.Header.Controls.Add(script);

}

解决方案

try to use

emp_mid= txtEmpmid.Text.ToUpper();



Remember one thing, numeric value is not having any type like upper or lower, so if you apply ToUpper on numeric value it simply return same value...


It looks like you need to use the method String.ToUpper(CultureInfo):

string myString = someString.ToUpper(System.Globalization.CultureInfo.InvariantCulture);


This way, you can be sure that even if some culture-specific form of digits is used, they won't be involved.

—SA


Try:

string details = GetRptDetails(txtEmpmid.Text).ToString().ToUpper();
ViewState["EmpDetails"] = details;


这篇关于将输入的字母数字数据转换为仅用于字母的大写字母的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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