Solved

Line 35

Posted on 2012-03-24
7
472 Views
Last Modified: 2012-03-26
This is the error that I am recieving. Can you help me.  I am a student needing tutoring and guidance.  The following errror is the problem in my program on line 35

Error      1      Property or indexer 'string.this[int]' cannot be assigned to -- it is read only      C:\Users\acer\Documents\TitleCase\Default.aspx      35      25      C:\...\TitleCase\

This is what I am trying to accomplish.

I must create a script that takes text that a user enters into a form field and converts it to title case capitalization.  Use a split()  method to split words in the string into an indexed array.  Then create a for loop that uses another split() method that splits each word in the elements of the indexed array into another another indexed array of characters.  Within the for loop, us he ToUpper() method to convert the first element in the second array (which represents the first characters in the word to uppercase) to uppercase, and then use the Join() method to rebuild the array of words in the text string.  Execute a final Join() method to convert the array of words back into a single text strin.  Save the project as TitleCase
TitleCase.zip
0
Comment
Question by:assaultkitty
7 Comments
 
LVL 35

Expert Comment

by:Miguel Oz
ID: 37761584
Can you post your code?
Default.aspx.cs does not contain any code:
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
}
0
 

Author Comment

by:assaultkitty
ID: 37761614
No, i do not have any code in it!  I am not using it.  Do I need to use it.  If so, then where do I start.  I got the HTML code to show.  Can you help?
0
 
LVL 16

Expert Comment

by:Vikram Singh Saini
ID: 37761911
No, i do not have any code in it!  I am not using it.  Do I need to use it.  If so, then where do I start.  I got the HTML code to show.  Can you help?


Show default.aspx as starting page and declare textbox in default.aspx page. And in Default.aspx.cs file, write code in button submit event hander as follow:

Code in .aspx.cs file:
string value = TextBox1.Text;
string upperValue = System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(value);

Open in new window

0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 15

Accepted Solution

by:
navneethegde earned 500 total points
ID: 37762170
Hi!

Create Extension method with vs00asini in codebehind
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

 
}

public static class myString
{
    public static string ToTitleCase(this string Input)
    {
        return System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(Input.ToLower());
    }

}

Open in new window


And use it in your HTML file

enteredText = enteredText.ToTitleCase();

Open in new window


Thanks!
0
 
LVL 16

Expert Comment

by:Vikram Singh Saini
ID: 37762494
Comment ID: 37762491 at link Line 33 would be the reason and solution for this problem too.
0
 

Author Comment

by:assaultkitty
ID: 37768698
I have to really trust the experts.  I did excellent on this project.   Thank you!
0
 

Author Closing Comment

by:assaultkitty
ID: 37768702
Thanks so much!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now