Click here to Skip to main content
15,901,035 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I want to convert the input alphanumeric data which we take from the textbox to the uppercase only for alphabets.


C#
protected void Page_Load(object sender, EventArgs e)

  {
      emp_mid= txtEmpmid.Text;

  }




C#
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);

}
Posted

try to use
C#
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...
 
Share this answer
 
v2
Comments
Member 10628913 10-Mar-14 8:19am    
Dear Sir,

r u sure about dis.coz id read sumvhr dat toupper() will convert the numbers into an equivalent aplhabet.Please inform.Thanks
Tejas Vaishnav 10-Mar-14 8:31am    
yes, number is not having any different value like Upper or Lower case.

if you provide value like "12$RerIuop*" then ToUpper() will return like this "12$RERIUOP*"
Sergey Alexandrovich Kryukov 10-Mar-14 10:27am    
Most likely so, but you cannot be 100% sure. Please see my answer and my comment to Solution 2.
Culture parameter should be used.
—SA
It looks like you need to use the method String.ToUpper(CultureInfo):
C#
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
 
Share this answer
 
v2
Comments
Peter Leow 10-Mar-14 11:02am    
Sergey, you are right. This link reinforced your point. +5!
Sergey Alexandrovich Kryukov 10-Mar-14 11:26am    
Thank you, Peter.
—SA
Try:
C#
string details = GetRptDetails(txtEmpmid.Text).ToString().ToUpper();
ViewState["EmpDetails"] = details;
 
Share this answer
 
Comments
Member 10628913 10-Mar-14 8:19am    
Dear Sir,

r u sure about dis.coz id read sumvhr dat toupper() will convert the numbers into an equivalent aplhabet.Please inform.Thanks
OriginalGriff 10-Mar-14 8:59am    
Please don't use txtspk here: you have a keyboard, so use it.

Yes, I'm sure: ToUpper and ToLower only affect alphabetic characters, they do not affect numerics or punctuation.
Sergey Alexandrovich Kryukov 10-Mar-14 10:26am    
No, you cannot be 100% sure, in general case. This is because the notion of "digit" can include some culture-dependent forms of digits, such as traditional Arabic. Even though they hardy can have upper and lower form, who knows. So, even though your advice will work in all or nearly all cases, to be on safe side, it's better to use neutral culture. Or, if the target culture is known and always the same, this particular culture. Please see my answer.
—SA
Member 10628913 12-Mar-14 1:06am    
Thanks alot sir..
Sergey Alexandrovich Kryukov 12-Mar-14 11:36am    
You are welcome.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900