Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Text Merge
Message
General information
Forum:
ASP.NET
Category:
Other
Title:
Miscellaneous
Thread ID:
00754274
Message ID:
00754610
Views:
20
Thank you David.

Slava

>>What is the best practice of text merges? Can VB.Net/SQL procedures merge the text? Does anybody have an example of merging a text with a function's result?
>
>In the Community Starter Kit for ASP.NET (http://www.asp.net/StarterKits) there is an example of merging and emailing a newletter to subscribers. Here is the pertinent code:
>
>        //*********************************************************************
>        //
>        // FormatContentText Method
>        //
>        // Formats email text with content specific information.
>        //
>        //*********************************************************************
>
>        public static string FormatContentText(string text, MailFormat bodyFormat) {
>            string matchText;
>
>            // Replace new articles
>            matchText = Regex.Escape("<NewArticles>");
>            if (Regex.IsMatch(text, matchText))
>                text = Regex.Replace(text, matchText, FormatContentCollection(ContentPageUtility.GetNewContent("Article"), bodyFormat));
>
>            // Replace new events
>            matchText = Regex.Escape("<NewEvents>");
>            if (Regex.IsMatch(text, matchText))
>                text = Regex.Replace(text, matchText, FormatContentCollection(ContentPageUtility.GetNewContent("Event"), bodyFormat));
>
>            // Replace new books
>            matchText = Regex.Escape("<NewBooks>");
>            if (Regex.IsMatch(text, matchText))
>                text = Regex.Replace(text, matchText, FormatContentCollection(ContentPageUtility.GetNewContent("Book"), bodyFormat));
>
>            // Replace new links
>            matchText = Regex.Escape("<NewLinks>");
>            if (Regex.IsMatch(text, matchText))
>                text = Regex.Replace(text, matchText, FormatContentCollection(ContentPageUtility.GetNewContent("Link"), bodyFormat));
>
>            // Replace new downloads
>            matchText = Regex.Escape("<NewDownloads>");
>            if (Regex.IsMatch(text, matchText))
>                text = Regex.Replace(text, matchText, FormatContentCollection(ContentPageUtility.GetNewContent("Download"), bodyFormat));
>
>            // Replace new photos
>            matchText = Regex.Escape("<NewPhotos>");
>            if (Regex.IsMatch(text, matchText))
>                text = Regex.Replace(text, matchText, FormatContentCollection(ContentPageUtility.GetNewContent("Photo"), bodyFormat));
>
>            return text;
>        }
>
>
>This is not the same as FoxPro's ability to evaluate and execute a string but it would be easy to follow this approach and simply replace the token Today with System.DateTime.Now.ToString.
Previous
Reply
Map
View

Click here to load this message in the networking platform