Hi...please store ur paragraph with some special characters.then u can easliy use the characters to split .example
hi this is for Maran.@@@
display a page with multiple paragraphs I stored the paragraph with a unique character in the database.@@@
use the special characters.
string.Split("@@@") to split
A.Venkatesan
Microsoft Certified Professional
Please mark the replies as answers if they help or unmark if not.
If you have any feedback about my replies, please contact venkatmca008@gmail.com
@{
var text="If you want to apply some kind of paging, you can do so with a database quite easily.¬¬ You just need to insert some kind of symbol into the content to denote where the page breaks are - something that isn't likely to appear there in the normal
course of events. The following code shows a helper that will split such an article into pages:";
var delimiter= "¬¬";
}
There are various different overloads for the String.Split method. None of them accept a string. Some accept a string array (plus at least one other argument) and the others expect an array of chars. Regex.Split will happily accept a string.
If you want to use a string array, try this:
@{
var text="If you want to apply some kind of paging, you can do so with a database quite easily.¬¬ You just need to insert some kind of symbol into the content to denote where the page breaks are - something that isn't likely to appear there in the normal course of events. The following code shows a helper that will split such an article into pages:";
var delimiter = new string[] { "¬¬" };
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
@MultiplePage(text,delimiter)
</body>
</html>
@helper MultiplePage(string input, string[] delimiter)
{
string[] paragraph = input.Split(delimiter, StringSplitOptions.None);
foreach( var text in paragraph)
{
<p>@text</p>
}
}
Maran
Member
37 Points
24 Posts
Create multiple Paragraph
Feb 22, 2012 03:26 AM|LINK
I am trying to to display a page with multiple paragraphs I stored the paragraph with a unique character in the database.
When I retreive I used string.Split() in the helper method. but it dosent work. Any one have an idea?
Thanks
dinesh kumar...
Participant
986 Points
247 Posts
Re: Create multiple Paragraph
Feb 22, 2012 04:05 AM|LINK
So you are getting one paragraph after concatinating all or the first paragraph after split??
Jai Jagannath
venkatmca008
Participant
1810 Points
341 Posts
Re: Create multiple Paragraph
Feb 22, 2012 04:20 AM|LINK
Hi...please store ur paragraph with some special characters.then u can easliy use the characters to split .example
string.Split("@@@") to splitMicrosoft Certified Professional
Please mark the replies as answers if they help or unmark if not.
If you have any feedback about my replies, please contact venkatmca008@gmail.com
Mikesdotnett...
All-Star
154858 Points
19858 Posts
Moderator
MVP
Re: Create multiple Paragraph
Feb 22, 2012 04:30 AM|LINK
Difficult to guess without seeing you code. Can you post the relevant bits?
Beginning ASP.NET Web Pages with WebMatrix | My Site | Twitter
Maran
Member
37 Points
24 Posts
Re: Create multiple Paragraph
Feb 22, 2012 01:11 PM|LINK
Mike Here is my code..
/--------------- helper method --------------------------/
@helper MultiplePage(string input, string delimiter)
{
string[] paragraph=input.Split(delimiter);
foreach( var text in paragraph)
{
<text> @text</text>;
}
}
/--------------- webpage ---------------------------------/
@{
var text="If you want to apply some kind of paging, you can do so with a database quite easily.¬¬ You just need to insert some kind of symbol into the content to denote where the page breaks are - something that isn't likely to appear there in the normal course of events. The following code shows a helper that will split such an article into pages:";
var delimiter= "¬¬";
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
@Helpers.MultiplePage(text,delimiter);
</body>
</html>
Mikesdotnett...
All-Star
154858 Points
19858 Posts
Moderator
MVP
Re: Create multiple Paragraph
Feb 22, 2012 04:34 PM|LINK
There are various different overloads for the String.Split method. None of them accept a string. Some accept a string array (plus at least one other argument) and the others expect an array of chars. Regex.Split will happily accept a string.
If you want to use a string array, try this:
@{ var text="If you want to apply some kind of paging, you can do so with a database quite easily.¬¬ You just need to insert some kind of symbol into the content to denote where the page breaks are - something that isn't likely to appear there in the normal course of events. The following code shows a helper that will split such an article into pages:"; var delimiter = new string[] { "¬¬" }; } <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <title></title> </head> <body> @MultiplePage(text,delimiter) </body> </html> @helper MultiplePage(string input, string[] delimiter) { string[] paragraph = input.Split(delimiter, StringSplitOptions.None); foreach( var text in paragraph) { <p>@text</p> } }Beginning ASP.NET Web Pages with WebMatrix | My Site | Twitter
Maran
Member
37 Points
24 Posts
Re: Create multiple Paragraph
Feb 22, 2012 05:12 PM|LINK
Thanks Mike. You are awesome..
Let me try with Regix.Split() and see if that works too.