Export other data that does not belong to the model

Andrei Ignat edited this page Jan 16, 2016 · 1 revision

Every Export function has a params KeyValuePair<string, object>

Here we add the created date into HTML

new KeyValuePair<string, object>("DateCreated",date));

#Code

public void TestViewBag()
            {
                //in the HTML export default exists  the following line
                //Generated on @ViewBag.DateCreated
                var p = new Person { Name = "Andrei Ignat", WebSite = "http://msprogrammer.serviciipeweb.ro/", CV = "http://serviciipeweb.ro/iafblog/content/binary/cv.doc" };
                var export = new ExportHtml<Person>();
                var date = DateTime.UtcNow;
                var data = export.ExportResult(new List<Person>() { p },new KeyValuePair<string, object>("DateCreated",date));
                var str = Encoding.Unicode.GetString(data);
                Assert.IsTrue(str.Contains(date.ToString()));


          }
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.