Capital First letter

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Aug 2009
Posts: 17
Reputation: sandeep_1987 is an unknown quantity at this point 
Solved Threads: 0
sandeep_1987 sandeep_1987 is offline Offline
Newbie Poster

Capital First letter

 
0
  #1
Sep 26th, 2009
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-

  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!!!
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 66
Reputation: reach_yousuf is an unknown quantity at this point 
Solved Threads: 12
reach_yousuf reach_yousuf is offline Offline
Junior Poster in Training

Re: Capital First letter

 
0
  #2
Sep 26th, 2009
Originally Posted by sandeep_1987 View 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-

  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)
  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.
Yousuf
Software Developer
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 433
Reputation: Ramesh S will become famous soon enough Ramesh S will become famous soon enough 
Solved Threads: 82
Ramesh S Ramesh S is offline Offline
Posting Pro in Training

Re: Capital First letter

 
0
  #3
Sep 26th, 2009
Try this code. It will convert the text into TitleCase using JavaScript.

  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>
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 17
Reputation: sandeep_1987 is an unknown quantity at this point 
Solved Threads: 0
sandeep_1987 sandeep_1987 is offline Offline
Newbie Poster

Re: Capital First letter

 
0
  #4
Sep 26th, 2009
hi reach,thx very much
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC