Background Color:
 
Background Pattern:
Reset
Search

Forum

Please Log In

We want you to contribute! 

This forum is a moderated environment. 
We try to keep it neat and tidy. In order to access the forum content we would like you to either or register.

HomeHomeScryberScryberDevelopment Que...Development Que...Using data:if with variables set with C# codeUsing data:if with variables set with C# code
Previous
 
Next
New Post
8/29/2016 3:27 PM
 

Is it possible to set a variable in C# (for instance: var london = 1;)  and then check it via xml?

We want to add extra content to our PDFs once london equals 1:

<data:if test="@london=1">

<!-- Extra Divs, Labels, etc... -->

</data:if>

Is there any way to use the variable called london to make our PDFs more dynamic?

 
New Post
9/4/2016 3:15 PM
 

Hi Dougy

If you haven't figured this one out yet (sorry - been travelling) then you can use the test if it's present in the xml data source.

However we also have the items collection and support see : http://www.scryber.co.uk/HowTo/tabid/133/Default.aspx?topic=Item+and+Query+String+Binding#itemxpath

This allows you to assign variables at run time to the collection and inspect them during generation e.g. visible='{item:IsLondon}'. It's strongly typed and doesn't support expressions, however you can extend the selectors will collections, dictionaries and complex objects e.g. visible='{item:Config.IsLondon}'

 

You can also look up the item during generation (after parsing and then set any options you require...

 

                using (doc = Scryber.Components.PDFDocument.ParseDocument(input))

                {

                    //Define the visibility of a component at runtime

                    doc.FindAComponentById("myPanel").Visible = (this.London == 1);

 

                    //Assign dymanic content within a componet

                    Scryber.Components.PDFComponent dynamic = this.GetMyCustomContent();

                    (doc.FindAComponentById("myPlaceholder") as Scryber.Components.PDFPlaceHolder).Contents.Add(dynamic);

 

                    doc.ProcessDocument(output);

                }


Hope this helps.

 
New Post
12/8/2016 5:06 PM
 

Thank you so much. This gives us more possibilities now.

 
Previous
 
Next
HomeHomeScryberScryberDevelopment Que...Development Que...Using data:if with variables set with C# codeUsing data:if with variables set with C# code