CodeVerge.Net Beta


   Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > Asp.Net Forum > general_asp.net.getting_started Tags:
Item Type: Date Entered: 7/12/2008 5:19:57 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 5 Views: 12 Favorited: 0 Favorite
6 Items, 1 Pages 1 |< << Go >> >|
"quilling123" <
NewsGroup User
Testing for upper case in a text box7/12/2008 5:19:57 PM

0

Hi,

 Say I have a text box t1, and t1.Text = "this Is an Example".  How do I search through this string and convert only the first letter of each word to uppercase?  The resulting string should look like t1.Text="This Is An Example"

I am using C#

Your help is greatly appreciated!

~Mark

"mbanavige" <>
NewsGroup User
Re: Testing for upper case in a text box7/12/2008 6:02:34 PM

0

A sample for converting a string to TitleCase can be found here: http://support.microsoft.com/kb/312890


Mike Banavige
~~~~~~~~~~~~
Dont forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
"Jeev" <>
NewsGroup User
Re: Testing for upper case in a text box7/12/2008 6:17:58 PM

0

 

1         private string UpperCaseSentence(string sRawInput)
2            {
3                if (string.IsNullOrEmpty(sRawInput))
4                {
5                    return string.Empty;
6                }
7                string[] sArrayInput = sRawInput.Split();
8                StringBuilder sBuilder = new StringBuilder();
9                for (int i = 0; i < sArrayInput.Length; i++)
10               {
11                   sBuilder.Append(UppercaseFirstLetter(sArrayInput[i]));
12                   sBuilder.Append(" ");
13               }
14               return sBuilder.ToString().TrimEnd();
15           }
16           public string UppercaseFirstLetter(string Input)
17           {
18               if (string.IsNullOrEmpty(Input))
19               {
20                   return string.Empty;
21               }
22               char[] stringChars = Input.ToCharArray();
23               stringChars[0] = char.ToUpper(stringChars[0]);
24               return new string(stringChars);
25           }
 
Jeev
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you get the answer to your question, please mark it as the answer.
"sahil31_mohali
NewsGroup User
Re: Testing for upper case in a text box7/12/2008 6:35:49 PM

0

Wink

jeev Your Code is fine.


sahil
"TATWORTH" <>
NewsGroup User
Re: Testing for upper case in a text box7/12/2008 6:55:40 PM

0

Try

    /// <summary>
    /// Lower case characters
    /// </summary>
    private const string FILTER_LOWER = "abcdefghijklmnopqrstuvwxyz";
    /// <summary>
    /// Upper Case Characters
    /// </summary>
    private const string FILTER_UPPER = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    /// <summary>
    /// Alpha (upper and lower) characters
    /// </summary>
    private const string FILTER_ALPHA = FILTER_LOWER + FILTER_UPPER;

    #region " Init... "
    /// <summary>
    /// Capitalise initial letters
    /// </summary>
    /// <param name="input">The input string</param>
    /// <returns>String with start of words capitalised</returns>
    public static string InitCaps(string input)
    {
      input = "" + input;
      StringBuilder output = new StringBuilder(input.Length);
      bool start = true;
      for (int i = 0; i < input.Length; i++)
      {
        string letter = input.Substring(i, 1);
        if (start && FILTER_ALPHA.Contains(letter))
        {
          output.Append(letter.ToUpper());
          start = false;
        }
        else
          output.Append(letter);
        if (letter == " ") start = true;
      }
      return output.ToString();
    }
    #endregion


Don't forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
"TATWORTH" <>
NewsGroup User
Re: Testing for upper case in a text box7/12/2008 6:58:08 PM

0

 The unit tests I used were:

    /// <summary>
    /// Test InitCaps
    /// </summary>
    [Test]
    public void TestInitCaps()
    {
      this.TestInitCapsTest("", "", true);
      this.TestInitCapsTest(null, "", true);
      this.TestInitCapsTest("A123", "A123", true);
      this.TestInitCapsTest("a123", "A123", true);
      this.TestInitCapsTest("hello world", "Hello World", true);
    }

    #region " TestInitCapsTest           "
    /// <summary>
    /// Test FilterUserName
    /// </summary>
    /// <param name="sIn">Input string</param>
    /// <param name="sExpect">Expected output</param>
    /// <param name="bExpect">Expected Test result</param>
    private void TestInitCapsTest(string sIn, string sExpect, bool bExpect)
    {
      string sOutput = CommonData.InitCaps(sIn);
      if (sExpect != sOutput)
      {
        Console.WriteLine("sOutput:" + sOutput);
        Console.WriteLine("sExpect:" + sExpect);
      }
      Assert.AreEqual(sExpect, sOutput);
    }
    #endregion


Don't forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
6 Items, 1 Pages 1 |< << Go >> >|


Free Download:













refreshing masterpages

bind treeview to ms access database (vb)

missing themes functionality

treeview sitemap, control expand / collapse

pass a var from content page to master page

can contentplaceholder controls be put inside the <head> tag?

problem with menu control and sitemap

menuitem enabled property not functioning properly in asp .net 2.0 (vwde)

masterpages and inheritance

sitemap nodes

looking for treeview css, that keeps view state examples and the css

html form inside of control not working...

how can i make my masterpage 100% in screan

handling a mulitivew control in a content page from a master page

2 contentplaceholders: click on a button from one to change another

trouble with xmlsitemapprovider

problem in using treeview

base pages, profiles and themes

menu display problems using masterpage

problem with nav menu

search node in a tree list!

background-image not rendering (masterpage, modalpopupextender)

can you catch a .master compile error?

controll id duplicate problem

error: circular file reference - what's causing this?

javascript onload, onresize -- gets "not a member of ...master" error

master pages + asp.net 2 + viewstate = problems!

utilising roles in generating a menu

menuitem style

treeview in ie and mozilla

how to access js files from a master page

how to set meta tags while using master page?

how to expand the current node to view automatically using sitemap and treeview control?

can i get help with this strange problem with my masterpage

nested masterpage help...

can you help me? - dynamicmenuitemstyle in .skin file

masterpages and sitemap on godaddy

top-level controls in a content page

customizing menu control for different styles for each

get info from customize treenode?

treeview issues

error in nov ctp i do not understand

using fdse with a masterpage

unable to access a property in master page

asp 2.0 menu postback

about treeview

treeview cycle

themes not working in redirectfromlogin page

menu control items not being selected, on_click not firing

best way for content page to set a property on its master page?

   
  Privacy | Contact Us
All Times Are GMT