Kentico ASPX+Portal templates not registering zones in database - asp.net

In Kentico I'm using ASPX+Portal model created a template as a webform on disk with a single widget zone as follows:
<asp:Content id="content" runat="server" ContentPlaceHolderID="content">
<h1>Home: <%= this.PageModel.DisplayTitle %></h1>
<cms:CMSPagePlaceholder ID="plcZones" runat="server">
<LayoutTemplate>
<cms:CMSWebPartZone ID="zoneEditorContent" runat="server" ZoneTitle="Page content" WidgetZoneType="Editor" />
</LayoutTemplate>
</cms:CMSPagePlaceholder>
</asp:Content>
I then registered this in Kentico's Page templates module.
Pages using this template would now show the zone on the Page tab but wouldn't let me add widgets to it. I could browse the widget library, select a widget, set its properties, save and close the dialogue, but the page would refresh remaining empty.
After some dabbling I discovered that the relevant template record in database table [dbo].[CMS_PageTemplate] had its [PageTemplateWebParts] property set to the value '<page />'.
I discovered that changing this to '<page><webpartzone id="zoneEditorContent" v="1" widgetzonetype="editor" /></page>' resolved the problem. I could now add widgets to the zone on the Page tab.
My question is, what am I doing wrong here? I presume I'm not supposed to set this database field manually. Should Kentico be doing this automatically, and if so, what step am I missing to make this happen? I believe I've followed Kentico documentation accurately.

You are not doing anything wrong. I have to agree this is weird behavior but it is not possible (= does not take any effect) to set WidgetZoneType property in markup. You need to set it manually via admin UI (zone properties). If this is issue for you consider to add it to Kentico`s User voice.
YMHO I think you are right and it should be at least mentioned in doc that it is not possible to use this property in markup.
EDIT: My bad, please note it is mentioned in the docs, too:
Changing the WidgetZoneType property directly in layout code does not save the changes in the database. You need to set the Widget zone type property by configuring the zone properties.

Related

Printing a "tag" with a barcode using reporting services and DB values in asp.net

Edit 7 : I finally made it! Posted the answer.
Edit 6 : I scrapped the CSS and div and used a reporting services. Look at edits down the post to see where I am at right now.
I'm at a complete lost right now.
Sorry if I am not clear enough with my question, I can edit it to add information if needed. I'll try giving as much info as possible.
I've searched on google for hours now and havn't find anything to help me.
I am trying to create multiple "tag" using information on a user I have in my database and putting them on a page to print them. Plus, I need only 1 tag per page.
I got a stored proc that returns to me the username, name and family name as well as an ID I use to generate a barcode for every users in a certain event.
CREATE PROCEDURE Schema.GetAllTags
#IdEvent int
AS
BEGIN
SELECT Mem.Nom, Mem.Prenom, Mem.Pseudo, Use.IdUser
FROM Schema.User Use
JOIN Schema.Member Mem ON Use.IdMember = Mem.IdMember
WHERE Use.IdEvent = #IdEvent
END
The barcode is generated by calling an asp page and giving it the ID I received from my stored proc in the page parameter. The asp page is an image that I use to show my barcode in other pages.
I tried making the tags using divs, CSS, asp content and all that stuff and it worked... except for the printing part. The tag being resized all the time, the margin not being an inch even tho I tried everything to make it 25.4mm (1 inch) and on top of it, the url of the page always showing in the preview print. All thoses problem could be solved by the client simply from unchecking the show url and setting the margin yourself in the options. But I don't want to force the client to do theses in order to fix the problem. I want it to be 3 by 2 in, with 1 in margin and no url without having to change printing options.
I was told using reporting services would solve my printing problems. But I have no clues how to make what I need out of reporting services (I know what reporting services are mind you)... even less on how to get my barcode in there.
Here what the tag should look like in the end on a print page. 3in x 2in with 1in margin on top and left when printing.
Here the CSS I used to try and print my tag :
<style type="text/css">
#page
{
margin: 25.4mm 25.4mm 25.4mm 25.4mm;
}
#media print
{
body *
{
visibility:hidden;
}
#tagPrint, #tagPrint *
{
visibility:visible;
}
#tagPrint
{
position:fixed;
top: 0px;
left: 0px;
}
#NOPRINT
{
display:none;
}
}
And here the asp (That is for my page with only 1 tag showing) :
<asp:UpdatePanel ID="UpdatePanel1" runat="server" >
<ContentTemplate>
<div id="tag" class="formRow">
<div id="tagPrint" style="border:1px solid;width:76.2mm;height:50.8mm">
<p style="text-align:center" />
<br />
<asp:Label ID="lblUserTag" runat="server" style="font-weight:bold;font-size:18px" />
<br />
<asp:Label ID="lblFullNameTag" runat="server" style="font-weight:bold;font-size:16px" />
<br />
<br />
<asp:Image ID="imgBarcodeTag" runat="server" />
<br />
<asp:Label ID="lblIdTag" runat="server" style="font-weight:bold;font-size:16px" />
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
Currently generating my tags using a repeater on my page to generate multiple tags and binding the dataset.tables[0].Rows to the repeater. Allowing me to create thoses tags.
Is there any ways to do it without reporting services using only javascript and CSS?
Is it doable with reporting services (Using an asp page in a reporting service to make a barcode)? Since my barcode come from a font, is there any other way then adding the font on the compiter in order to use it in reporting services? (I don't want the client to have to install the font) Would making a pdf of the tag easier/better?
Edit : Started working around with a report service.
Right now I got the report made with 4 parameter. (Username, full name, barcode url and the ID)
I'll give update on what happens next.
Edit 2 : So... after managing to make a report service and showing it in the page. I can't seem to get my image to show on the report. And even if I did. I don't know how to make multiple page on the report or how to print it.
I decided to try making my Div Tag in PDF instead and try to print it that way. I'll update tomorrow when I get the chance to try it.
Edit 3 : Aside from wanting to smash my head on a wall several times, I tried doing it in PDF and it's not working. Found out it can probably be done in flash, but I do not want to do it in flash. So I'm back to the report service.
I made a report service with a grid where I send my dataset to the grid and put the datas in each fields. I installed the font to be able to use it in the report. Now I can't seem to bind my dataset to the report. I tried an SqlDataSource and ObjectDataSource and nothing seems to work. I started another report in a new project to try from scrap. Maybe something from my current project is playing against me.
I'm about to give up. -_-
Edit 4 : I finally made it to get something working. Got my report on my page working just fine.
Now only thing I have left to do... is manage to get the report to have multiple page.
Edit 5 : Rereading my edits and I realized I forgot to say that slightly after edit 2, I scrapped the parameters stuff and used a dataset instead. Also, I scrapped everything about CSS and the div to use a reporting service to save a PDF file of the tags.
So let me just preface this with a bit of explanation about SSRS: You're doing it all wrong.
By that I mean, if you're just trying to embed your ASP code and output in SSRS to achieve graphical fidelity, it's not going to happen.
The reason SSRS was recommended to you is because it can take a set of data and reproduce it with high graphic fidelity in a variety of reporting styles, formats, and output methods.
But you have to build it from scratch. No HTML, no CSS, no ASP, no .Net (well .. sort of. For you, yes, no .Net required.)
Whoa, whoa, whoa, where you going? It's not that hard, I promise.
So ... first, let's just set up a task list for you to do this in SSRS. Before we can even do that, let's just build a wizard-driven report so we can get your ID tag data set into the report. It'll give you a basic feel for how SSRS consumes data and turns it into a report.
Create a brand-new Reporting Services project.
Add a new report to this project. In the Solution Explorer, right click on the Reports folder and "Add New Report."
Step one is select the data source. Hook it up to your database with the stored procedure you're running, test your connection, moving on.
Next step is to Design the Query - but you've already done that with your Sproc, so just paste that in - for now, add a hardcoded value for your IdEvent. We'll fix that later.
Now choose your report type - let's just do Tabular for now. Matrix is more for lots of row/column dynamics, and you're just looking for a simple printable report, so table for you.
Now in designing the table, just add all of your output columns to the Detils group.
Choose any old Table style, you're throwing this all away in the end.
Name your report something useful and finish.
Now you've got a RDL, it's got a data source, a data set, and some code in the designer area. You can preview what you've done so far by clicking the "Preview" tab in the designer area. Pretty sweet, there's all your data, in little rows in a table. Now what?
Now for the task list. Start Googling, you can learn all of this, it won't take too long, and when you're done, you'll have a well-formatted set of ID tags ready for the printer. And if you run into specific issues - well, that's what this site is for, right?
Create a parameter to pass in your IDEvent to your stored procedure.
Insert a dynamic external image into the row that retrieves the barcode from your ASP page. (Hint: read up on using "Expressions" in SSRS.)
Figure out how to use the page break options in SSRS to only print 1 tag per page.
Use the properties window to format each "row" of your table to look like your tag.
Figure out whether to export your report as a PDF, or just use the MHTML version provided.
You might also potentially want to learn how to embed an SSRS report in a .Net application (how are you clients printing the tags, anyway?) And of course there are tons of little methods, properties, and aspects of SSRS that are out of scope for this particular task but might be worth at least taking a look at for later projects.
Good luck!
Finally! I made it!
Here what I did.
Made a SSRS.
Made a report viewer and ObjectDataBinder
Create a DataSet for the SSRS using my stored proc.
Bound the report viewer to the SSRS.
Play around the SSRS to place the fields like they need to be placed.
Set page margin in SSRS to 1 inch. Set the report to 3x2 inch.
Set the report size to 5x4 inch.
Tested and enjoyed my victory over theses hours of frustration.
Note : It took me lot of time because visual studio bugged on me and I had to delete and redo my SSRS entirely.
Result :
A beautiful PDF file with perfect size, margin that print perfectly WITH a codebar. VICTORY!

Should I use tcdl, Tridion tag, or RenderComponentPresentation?

Managing a "Global" Logo with Tridion
To manage, for example, a website-wide logo and its text elements with SDL Tridion, I'd want it in a component, rendered by a (dynamic) component template, and placed by page templates. My requirements would include:
Logo as a Component--image as a multimedia (mm) component and link, alt (i.e. "home"), and other text in an optional container component
Dynamic Component Presentation (DCP)--ability to manage logo's markup presentation and publish changes without requiring publishing every page
Share-able--ability to localize multimedia and text in components, rather than templates, in lower publications
Authors shouldn't need to place the logo as a component presentation (CP) on every page, although a logo CP just on the homepage could offer dynamic linking.
RenderComponentPresentation(), TCDL, or Tridion tags for "Non CPs"
For this CP-less approach, I think RenderComponentPresentation() or TCDL tag would be the right "agnostic" approach. Is one preferred over the other?
For example, my template outputs:
<h3>By tridion: (ASP.NET) tag</h3>
<tridion:ComponentPresentation runat="server"
PageURI="tcm:7-1535-64"
ComponentURI="tcm:7-1533"
TemplateURI="tcm:7-1532-32"/>
<h3>By tcdl: tag</h3>
<tcdl:ComponentPresentation
PageURI="##Page.ID##"
type="Dynamic"
ComponentURI="tcm:7-1533"
TemplateURI="tcm:7-1532-32"/>
<h3>by render component presentation</h3>
##RenderComponentPresentation('tcm:7-1533','tcm:7-1532-32')##
These get transformed to the following on the file system.
<h3>By tridion: (ASP.NET) tag</h3>
<tridion:ComponentPresentation runat="server"
PageURI="tcm:7-1535-64"
ComponentURI="tcm:7-1533"
TemplateURI="tcm:7-1532-32"/>
<h3>By tcdl: tag</h3>
<tridion:ComponentPresentation runat="server"
PageURI="tcm:7-1535-64"
ComponentURI="tcm:7-1533"
TemplateURI="tcm:7-1532-32"/>
<h3>by render component presentation</h3>
<tridion:ComponentPresentation runat="server"
PageURI="tcm:7-1535-64"
ComponentURI="tcm:7-1533"
TemplateURI="tcm:7-1532-32"/>
Each renders delivery-side so the user sees the correct CP in the browser.
Question(s):
Any approach gets us a DCP referenced from a PT with an agnostic format that gets retrieved presentation-side, avoiding full-site publishing. It's not really on the page so we have to be sure to publish the logo with a dynamic CT (it's html fragment in this case). Am I missing anything?
Is RenderComponentPresentation() preferred over TCDL or a specific presentation-side syntax? Any reason I'd actually want <tridion:ComponentPresentation runat="server"> instead?
Edit: I was missing the Type="Dynamic" attribute and value, also for a moment thought RenderComponentPresentation didn't create the right CP reference.
Basically you have answered your first question yourself already I think, apart from how you want to write it out in your template you have your DCP there.
My preference would be to use ##RenderComponentPresentation('tcm:7-1533','tcm:7-1532-32')## but I would actually not use it with hardcoded TCMURIs. I'd probabaly write a TBB which reads the Multimedia Component TCMURI and its Template URI somewhere from for instance a configuration Component or the Publication metadata, then your template could look something like:
##RenderComponentPresentation(${LogoUri}, ${LogoTemplateUri})##
When using Dreamwever TBBs for your layout, I would use this as a preference. If you are using another way of layout, then the next best thing would be to use the TCDL tag. Indeed to try and keep your templates code agnostic. The only time I would ever revert to writing out the tridion control code myself, is when I cannot get it there another way.

How can I add properties/attributes to an HTML markup container tag in ASP.Net

I've seen all of the usual pages with information about how to create a sub-tag that allows content within a user control (using ITemplate and INamingContainer) but I've yet to see anyone able to add properties that become attributes to said tags, for example:
<asp:MyControl runat="server" ID="myControlTest" SomeAttribute="SomeValue">
<Content ContentAttribute="Something">
Blah
</Content>
</asp:MyControl>
If you see the ContentAttribute on the Content tag, that is what I'd like to be able to achieve, but if I set it all up using ITemplate and INamingContainer etc, I can add a property that does in fact appear in Intellisense for that tag but when I run the code, it says Content does not have property/attribute named ContentAttribute (it also gives the same as a warning in VS IDE but still allows me to compile it).
I have tried everything to make this work and so far the only way seems to be if I make the Content property on MyControl a class that inherits from System.Web.UI.Control and implements ITemplate. That works but unfortunately I have to specify the runat attribute on the Content tag (because it sees it as a control rather than a sub-tag) and I'd rather not do that if possible.
Hope I have explained this well enough, if I haven't please let me know and I'll do my best to elaborate further.
Thanks in advance.
I think what you're proposing is something like a MIME email where there are a variable number of sections, each with an identifier for the client to choose the best version of the email it can handle. I assume you're wanting to select the appropriate template at runtime, based on that attribute.
The standard .NET controls don't implement that way, so far as I can tell. Think of the Repeater which has:
<asp:Repeater id="myRepeater" runat="server">
<HeaderTemplate>...</HeaderTemplate>
<ItemTemplate>...</ItemTemplate>
<FooterTemplate>...</FooterTemplate>
</asp:Repeater>
Each of the subitems (templates) has a different name, not the same name with a separate attribute.
Is there any way for you to define, ahead of time, what all of the possible sections might be, the way the repeater does?
<asp:MyControl runat="server" ID="myCtlTest">
<SomethingTemplate>Blah</SomethingTemplate>
<OtherTemplate>Blah</OtherTemplate>
</asp:MyControl>
I'm guessing not but wanted to throw it out there in case.
Alternately, could the ContentAttribute move to MyControl? The SETter would then load/build the template for you depending on the value.
<asp:MyControl runat="server" ID="myCtlTest" ContentAttribute="Something">
<Template></Template>
</asp:MyControl>
...or it could be loaded with a method instead of using the property SETter.
If you will always need multiple templates, perhaps a combination of those two concepts would help.
<asp:MyControl runat="server" ID="myControlTest"
SomethingTemplate="Something"
OtherTemplate="Other">
<SomethingTemplate></SomethingTemplate>
<OtherTemplate></OtherTemplate>
</asp:MyControl>

weird Ajax ComboBox drop down list

I've got combobox inside some panel :
<ajaxToolkit:ComboBox
ID="YearList"
runat="server"
OnInit="YearList_Init1"
EnableTheming="false"
Width="45px"
ViewStateMode="Disabled" />
and it was OK before I updated project to .NET 4 , after updating project (And AJAX) to .net4 it's looking like really strange ... I can't explain it proper , I will show :
how can I fix it ? :) Full CSS / ASPX page here -> https://github.com/nCdy/Issues/tree/master/Ajax%20ComboBox (string # 287)
I had a similar issue and could resolve mine by removing the extender that I had added to the Panel containing the combobox. I had used a DropShadowExtender for the Panel, removing it caused the combobox to be displayed perfectly. Perhaps you can try that as well.
i am seeing a lot of texts like
Контрактный час
:
, every where in your form. So i need to know, are you using some sort of encoding , that is, is this placed by you or came unexpectedly. If you havent placed it, remove all unneccessary such lines and use plain text instead (if required). Then check the layout.
Also in your image, i can see , ur language is russian(if i am right :)). So try using your localized font that is direcly supported by aspx as we use english or better use resource file instead of the hardcoded text on the page. As per my view the language conversion is creating such issue.

creating help for asp.net website

My requirement is to have database based help system for asp.net website, as shown in the image below. i have searched web but could not find even remotely related solution.
DNN Help System http://img3.imageshack.us/img3/6720/dnnhelpimage20091125.jpg
You could assign each help item a unique ID (perhaps GUID to make it easier to generate by the developer enabling help for that item).
Clicking on the link opens a dialog, tooltip, new window, whatever. Just have the UI load the help text by ID from the database.
To make this easier to implement in the UI, there are a few ways. Perhaps you can create a jQuery client-side behavior.
your HTML would look something like:
<span class="help" id="#{unique-id-here}">Admin</admin>
and you could have jQuery on DOM load:
$(function() {
var help = $(".help");
help.prepend("<img src=\"path/to/images/help.png\" />");
help.click(function() {
//do something with this.id; open a popup, a title bar, whatever.
}
});
We did it on our site by doing the following:
We have a HelpTopics database with a HelpTopicId and HelpTopicText
We create an aspx page that displays the HelpTopicText based on the HelptopicId passed in the querystring.
We set up a css class for the A tag that displays the link to the help with the question mark image.
We created a UserControl named TitleandHelp that contained a link to the page mentioned in step 2 and the style for the link set to step 3 above: The usercontrol has a public rpoperty for the title and one for the topicID (We called it HelpContext).
We add the usercontrol to the aspx page where appropriate
<uc2:titleandhelp ID="titleandhelp1" runat="server" HelpContext="4" PageTitle="Forgot Password" />
it may sound like a lot of work, but really it only takes a half hour or so to do all of the setup. The rest of the work lies in populating the table and dragging the usercontrol onto the pages where appropriate.

Resources