943,649 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Marked Solved
  • Views: 1709
  • ASP.NET RSS
Sep 26th, 2009
0

Capital First letter

Expand Post »
Currently I have two textboxes & one button, Suppose In One textbox1 i write sandeep gupta after clicking on button in textbox2 Sandeep Gupta is dere using the foll. code-

ASP.NET Syntax (Toggle Plain Text)
  1. protected void Button1_Click(object sender, EventArgs e)
  2. {
  3. string capitalized = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(TextBox1 .Text);
  4. TextInfo UsaTextInfo = new CultureInfo("en-US", false).TextInfo;
  5. TextBox2 .Text = UsaTextInfo.ToTitleCase(txtName .Text );
  6. }


I want that Text in textbox1 changes to Sandeep Gupta when i press tab to move to next field. I dont know which event to use, can u tell me!!!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sandeep_1987 is offline Offline
17 posts
since Aug 2009
Sep 26th, 2009
0

Re: Capital First letter

Currently I have two textboxes & one button, Suppose In One textbox1 i write sandeep gupta after clicking on button in textbox2 Sandeep Gupta is dere using the foll. code-

ASP.NET Syntax (Toggle Plain Text)
  1. protected void Button1_Click(object sender, EventArgs e)
  2. {
  3. string capitalized = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(TextBox1 .Text);
  4. TextInfo UsaTextInfo = new CultureInfo("en-US", false).TextInfo;
  5. TextBox2 .Text = UsaTextInfo.ToTitleCase(txtName .Text );
  6. }


I want that Text in textbox1 changes to Sandeep Gupta when i press tab to move to next field. I dont know which event to use, can u tell me!!!
Hi Sandeep

1) set Autopostback Property = true of Textbox1
2)
ASP.NET Syntax (Toggle Plain Text)
  1. protected Sub Textbox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtNewJobRankSerial.TextChanged
  2. 'USE YOUR CODE.
  3. TextBox2 .Text = UsaTextInfo.ToTitleCase(txtName .Text );
  4. End Sub
  5.  

Mark as solved if it hepls you!!!
Last edited by reach_yousuf; Sep 26th, 2009 at 4:46 am.
Reputation Points: 12
Solved Threads: 38
Junior Poster
reach_yousuf is offline Offline
194 posts
since Sep 2007
Sep 26th, 2009
0

Re: Capital First letter

Try this code. It will convert the text into TitleCase using JavaScript.

ASP.NET Syntax (Toggle Plain Text)
  1. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="DemoPage21.aspx.cs" Inherits="DemoPage21" %>
  2.  
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4. <html xmlns="http://www.w3.org/1999/xhtml">
  5. <head runat="server">
  6. <title></title>
  7.  
  8. <script type="text/javascript" language="javascript">
  9. function Trim(strIn) {
  10. strOut = strIn;
  11. strOut = strOut.replace(/^ */g, "");
  12. strOut = strOut.replace(/ *$/g, "");
  13. return strOut;
  14. }
  15.  
  16.  
  17. function TitleCase(oField) {
  18.  
  19. var myValue = oField.value
  20. var htext = Trim(myValue);
  21. htext = htext.toLowerCase();
  22.  
  23. htext = htext.substr(0, 1).toUpperCase() + htext.substring(1, htext.length);
  24. for (var i = 1; i < htext.length; i++) {
  25. if (htext.substr(i, 1) == " ") {
  26. while (htext.substr(i, 1) == " ")
  27. i++;
  28.  
  29. if (i + 1 < htext.length)
  30. htext = htext.substr(0, i) + htext.substr(i, 1).toUpperCase() + htext.substring(i + 1, htext.length);
  31. else
  32. htext = htext.substr(0, i) + htext.substr(i, 1).toUpperCase();
  33. }
  34. }
  35. return htext;
  36. }
  37.  
  38. </script>
  39.  
  40. </head>
  41. <body>
  42. <form id="form1" runat="server">
  43. <div>
  44. <asp:TextBox ID="TextBox1" onblur="this.value=TitleCase(this);" runat="server" />
  45. <asp:TextBox ID="TextBox2" runat="server" />
  46.  
  47. </div>
  48. </form>
  49. </body>
  50. </html>
Reputation Points: 165
Solved Threads: 113
Posting Pro
Ramesh S is offline Offline
580 posts
since Jun 2009
Sep 26th, 2009
0

Re: Capital First letter

hi reach,thx very much
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sandeep_1987 is offline Offline
17 posts
since Aug 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: Trouble with ConnectionString - What is my User ID and password
Next Thread in ASP.NET Forum Timeline: asp.net Label is an ambiguous reference





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC