I am using Codesmith 5.1 with Nettiers templates to to build an admin website that will let users edit data in different tables. I am using Nettiers functionality out-of-the-box and using the website it generates.
I want to conditionally hide a part of a webpage (not generate that part of the page).
As an example, I am allowing users to add/edit BondType which is reference data. I do not want them to add a bond record on the same screeen. So the stuff below Update/Cancel button needs to be hidden.
How do I do that conditionally? Which template(s) should I edit?
Bond Type - Add/Edit
I do not think my screen shot saves as good as it looked in preview. Typeshortdescription and Monetary Value are attributes of a BondType record. Just below the Monetary value attrbute are two button named Update and Cancel. I want the stuff below the two buttons (no Bond Found! Add New) to be hidden or not generated. How do I accomplish that with templates?
Hello,
You would need to update the following template (ASP.NET\Common\Admin\Entity.aspx.cst).
Thanks
-Blake Niemyjski
Blake Niemyjski CodeSmith Tools, LLC. Software Development Engineer Blog: http://windowscoding.com/blogs/blake/ .NetTiers team | Visit http://www.nettiers.com
I was thinking about editing the EntityEdit.aspx.cst instead of Entity.aspx.cst. But I’ll go by your advice.
So in the Entity.Aspx.cst, I am planning to edit the following line of code (changed code is in bold)
//Related Table must be in SourceTables
//Must be OneToMany relation
//Must not be a junction table
//must not be a non-reference table i.e. a table without the word type in it
if (!SourceTables.Contains(relatedTable)
|| ci.CollectionRelationshipType != RelationshipType.OneToMany
|| IsJunctionTable(relatedTable)
|| !relatedTable.FullName.Contains(“Type”))
continue;
Will this work?
Do I need to edit any other template? What about the code-behind file?
I’ll try this out later today but just wanted to check with you if I am making the changes in the right direction.
Hi Blake,
I made the exact same change to the code-behind template. So I made this change to the following two files:
EntityEdit.aspx.cst
EntityEdit.aspx.cs.cst
The generated web pages look what I expected. I managed to run the application via browser and updated some records. Can you verify this on a local test and confirm if I made the right changes? For some reason, I cannot get the web solution to compile. Thats why I am asking for help.
That code looks good, I would change it to do an EndsWith("Type"). What build errors are you receiving?