Click here to Skip to main content
15,904,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Original source code:
HTML
<form action="demo.asp" method="get" target="_blank">
First name: <input type="text" name="fname"><br>Last name: <input type="text" name="lname"><br><input type="submit" value="Submit">
</form>


New source code:
HTML
<form action="demo.asp" method="get" target="_blank">
  <input type="hidden" name="csrfPreventionSalt" value="<c:out value="${csrfPreventionSalt}" xmlns:c="#unknown" />"/>
  First name: <input type="text" name="fname">
  Last name: <input type="text" name="lname">
  <input type="submit" value="Submit">
</form>

based on example above is the any way to change from the Original source code in to the new source code? the new one will add extra code like
HTML
<input type="hidden" name="csrfPreventionSalt" value="<c:out value="${csrfPreventionSalt}" xmlns:c="#unknown" />"/>

or replace the word 'get' to 'post' without affecting other part of the coding

What is it called when adding few line of extra code in to original completed code?
Posted
Updated 24-May-13 3:42am
v4
Comments
Sunasara Imdadhusen 24-May-13 0:26am    
What are you trying to achieve??
Member 10032346 24-May-13 9:13am    
system that can change add on some codes to the original completed code.
TorstenH. 24-May-13 2:15am    
let#s use proper tags. This is no C and no Java.
Member 10032346 24-May-13 9:14am    
ok
Richard MacCutchan 24-May-13 10:28am    
What is it called when adding few line of extra code in to original completed code?
Modification.

If you don't mind would you please check on the post of the following link
http://stackoverflow.com/questions/16807052/how-to-add-modify-code-to-existing-source-code-programmatically[^]
 
Share this answer
 
Comments
Richard MacCutchan 29-May-13 3:11am    
OK, and what information is that supposed to convey?
Member 10032346 29-May-13 9:11am    
Just an over all more specific description. The system need reading the code from the textbox, Reading the string to look for a newline and input specific code in that line, and show the output. Reading the string to look for a newline and input specific code in that line would be the problem. Is there material that can teach me how to Reading the string to look for a newline?

User input may be vary but the key point is that the input will have things similar like this " <form action="demo.asp" method="get" ...>";. So how can I make the system to read it and apply adding code on the back of it or modify it while having all other code remain the same.
Richard MacCutchan 29-May-13 12:43pm    
If you don't know how to get the contents of a textbox and split it into separate lines, then I think maybe this project is a bit beyond your current skills. Take a look at the string class in .NET, with particular reference to its Split method. How you do the rest of it is still something that I cannot offer suggestions for.
Member 10032346 30-May-13 6:20am    
Due to some reason i am forced to go with this project.
Is there any way to make the system recognise pattern like " <form action="demo.asp" method="get" ...>" ? I need it to detect the word like method="get" or form action= . The specific code might be add on after those pattern or words. It may not necessary add in the end of a line or between lines.
Richard MacCutchan 30-May-13 6:28am    
Sorry, but you are still not explaining what you are trying to do. The statement "Is there any way to make the system recognise pattern like " <form action="demo.asp" method="get" ...>" ?" makes no real sense. You need to explain what platform you want to develop on, what language you are coding in, and what results you expect from this process. Up to now all you have told us is that you want to read some text and add some lines into it somewhere. But we still don't know what you expect to happen with this modified text.
Here is a sample that I tested
C#
string oritext  oritextBox.Text;
int index2 = oritet.IndexOf("of ");
string shakespeare2 = oritext.Insert(index2 + "of ".Length, "the ");


The input: The Attack of Titan
The output: The Attack of the Titan

So the output is consider what I wanted because it search the specific word "of " and add "the " behind of it. Is there a way to add in front of the "of " instead of behind? I had try using the string replace method :

string rpl = oritext.Replace("of ", "one of ");

The output: The Attack one of the Titan

Well the output works when both combine but I like to know is there a way without using the replace method.
 
Share this answer
 
Comments
Richard MacCutchan 11-Jun-13 12:19pm    
As with all such issues, it depends what you need to do. The best thing to do is to try all the methods provided by the class that can be used to insert or modify the contents, and then decide which is the one that works for your problem.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900