1

I have some javascript code written on top of c# with string builder like following:

StringBuilder cstext = new StringBuilder();

How to write these two lines without any syntax error, I am facing problems with writing those lines:

cstext.Append("data.setFormattedValue(row, 0, data.getFormattedValue(row, 0).replace(/src=".*"/i, 'src="' + src + '"'));"); 

(Error here is in this part (/src=".*"/i, 'src="' + src + '"'));)

and

cstext.Append("if(childrenOfChildren == "")");

(Error is here == "" its facing conflicts with other "")

Sorry for this non understand question but I can't explain better. Thanks

2 Answers 2

2

You have to replace the double quotes with escaped doubles quotes :

StringBuilder cstext = new StringBuilder();
cstext.Append("data.setFormattedValue(row, 0, data.getFormattedValue(row, 0).replace(/src=".*"/i, 'src=\"' + src + '\"'));");
cstext.Append("if(childrenOfChildren == \"\")");
Sign up to request clarification or add additional context in comments.

Comments

1

Try to use escape char \

cstext.Append("data.setFormattedValue(row, 0, data.getFormattedValue(row, 0).replace(/src=\".*\"/i, 'src=\"' + src + '\"'));");

And

cstext.Append("if(childrenOfChildren == \"\")");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.