Presentation Error - SmartTarget Page - tridion

When I open an Webpage with SmartTarget configured, I am getting two different errors:
Error 1
First time I get this error:
Server Error in '/' Application.
--------------------------------------------------------------------------------
com/tridion/marketingsolution/profile/Contact
================================================
Some configured classpath roots cannot be found
================================================
ClassPath : C:\tridion\Publicationsites\TestRD\staging\bin\bin
I am not sure how Line 2, comes into the picture, but when I add another bin folder within the already existing bin folder, the error goes. Is something wrong with any of the config file?
Error 2
When I open the page after I apply the workaround for the above error, I receive the following error
Unknown server tag 'smarttarget:Query'.
<smarttarget:Query View="lister" AllowDuplicates="true" Timeout="5000"
Publication="tcm:0-14-1" runat="server" Id="as">
Line 3: <smarttarget:Item runat="server" TemplateUri="tcm:14-1319-32"
ComponentUri="tcm:14-1321"></smarttarget:Item>
Where do I need to add the smarttarget tag? Should it be in the web.config file? Can you please share the syntax. I have tried to accurately implement the ST as mentioned in the live docs. Any area that I need to recheck?
Question 3
I am pasting a screenshot of my Compound Page Template below:
When I publish this page, the HTML markup present in the Main Page Design TBB is not published at all. Only the markup generated by the Add SmartTarget to Promotion TBB exist in the aspx Page.
<smarttarget:Query View="lister" AllowDuplicates="true" Timeout="5000"
Publication="tcm:0-14-1" runat="server" Id="as">
<smarttarget:Item runat="server" TemplateUri="tcm:14-1319-32"
ComponentUri="tcm:14-1321"></smarttarget:Item>
<smarttarget:Promotions MaxItems="2" Region="sidebar" runat="server">
<ItemTemplate>
<smarttarget:PromotionalItems runat="server">
<ItemTemplate>
<tridion:ComponentPresentation runat="server"
PageURI="tcm:14-1119-64"
ComponentURI="<%# Eval("ComponentUri") %>"
TemplateURI="<%# Eval("TemplateUri") %>"/>
</ItemTemplate>
</smarttarget:PromotionalItems>
</ItemTemplate>
<FallbackContent>
<tridion:ComponentPresentation runat='server'
ComponentUri='tcm:14-1322'
TemplateUri='tcm:14-1323-32'/>
</FallbackContent>
</smarttarget:Promotions>
</smarttarget:Query>
Is my implementation correct ?

That's a lot of questions in one entry, but I'll try to answer them here.
Looks like you don't have the right Tridion home directory and it ends up checking 'bin' under the current directory instead. See my blog post on the subject on how this is figured out (and thus how you can solve it): How Tridion Content Delivery loads configuration files (.NET)
This is standard .NET functionality. You can define a prefix in the same page or, as recommended, in the web.config. The exact markup for the web.config is: <add tagPrefix="smarttarget" namespace="Tridion.SmartTarget.Web.UI" assembly="Tridion.SmartTarget" />
Only one "Output" item is used from the package (the last one added). So the way you've split up your Dreamweaver Templates currently would indeed mean that you only get the output from "ST Page Region". I don't know what the intention was with it, so I can't suggest a good way to solve it aside from getting rid of it and putting the tcdl:region directly inside "Main Page Design TBB".
Good luck with it :)

Related

Same piece of code works on one page & doesnt work on other Page, asp.net

nesting of image inside a LinkButton shows image on one page & doesn't show image on another page below are two sample code from two different pages in the same root director.It works fine on one page but on the other page is doesn't show any download image rather shows the text download in place of image.
I have done troubleshooting for sometime and replace the code also but it doesnt show download image for any reason on the second page..
<asp:LinkButton ID="lnkbtnDownload" runat="server" onclick="lnkbtnDownload_Click" meta:resourcekey="lnkbtnDownloadResource1">
<asp:Image ID="imgDownload" runat="server" ImageUrl="~/images/download.png" meta:resourcekey="imgDownloadResource1" />
</asp:LinkButton>
<asp:LinkButton ID="lnkbtnDownload" runat="server" onclick="lnkbtnDownload_Click" meta:resourcekey="lnkbtnDownloadResource1">
<asp:Image ID="imgDownload" runat="server" ImageUrl="~/images/download.png" meta:resourcekey="imgDownloadResource1" />
</asp:LinkButton>
HTML OUTPUT
HTML for above two code sample render as below
<img alt="Download" src="images/download.png" id="MainContent_imgDownload">
Download
Both Pages are in the same root directory...
The problem probably comes from a discrepancy in your resource files or missing a resource file completely for the second page. Obviously you have one for the first, but possibly not for the other which has different naming.
If you are using meta:resourcekey, there are some things you have to considerate.
Make sure that your local resource files meet the following criteria:
They are in an App_LocalResources folder.
The base name matches the page name.
For example, if you are working with the page named Default.aspx, the
resource files are named Default.aspx.resx (for the default
resources), Default.aspx.es.resx, Default.aspx.es-mx.resx, and so on.
The resources in the file use the naming convention
resourcekey."property". For example, key name Button1."Text".
Source: MSDN

Can't reference controls in code behind. Visual Studio 2012

There are quite a few questions out there regarding this (for me, recurring) issue, but none of them have solved my problem.
Problem:
Whatever control I add in my aspx page, it is not recognised in the codebehind. Compiling doesn't work, because the ID is not recognised.
None of the following worked:
Clean and rebuild solution.
Close and open VS
Delete asp.net temp files
Check project's target framework.
Check assemblies are all there.
Check designer viewn to see if the control is actually there (it is)
Get control's ID with JS function to check it is the intended one (it is)
The problem has started only recently. In fact, I can reference the older controls fine.
The problem is observed both with standard ASP controls and Telerik ones.
Does anyone know of something else I should try? Please help me, I'm in the middle of a project and this is causing unnecessary delays, ta.
Make sure all of your asp.net controls (in the .aspx file) have the:
runat='server'
tag... Without this, you will not be able to reference the controls.
e.g.
<asp:Label runat='server' Text='Test Label' ID='TestLabel' />
Hope this helped...
Rodit
This is how I solved my issue. For a full account of it, please refer to the comments above.
I've noticed that although my project was already of web application type, designer files weren't showing.
I've forced the designer files to be recompiled by clicking on the ''convert to web application' option
I was then able to reference the control ID.
Thanks to the commentators anyway.
I was having a similar issue, due to the fact that I was using the pre-generated Login page. My solution was to change this section from this:
<asp:Login runat="server" ViewStateMode="Disabled" RenderOuterTable="false">
<LayoutTemplate>
To this:
<asp:Login ID="asplogin" runat="server" ViewStateMode="Disabled" RenderOuterTable="false">
<LayoutTemplate>
basically, I just added an ID to the asp:Login which allowed me to access the objects in the code from behind by prefixing the control name with asplogin
asplogin.youControlNameHere

ASP.Net Page Template and using asp tag in rendered pages

I want to use page templating in ASP.Net (Visual Studio 2012 with .Net 4.0).
The base page emits the basic template inclusive of the body, html, form, and other tags. That means the rendered pages just have what goes inside the body part. The template adds the header and footer. Although I have not finalized a design, I am looking at a concept documented here. (Yes, I know that coding practice is to not give links to pages, which can go away, but I do not want to side track the question.)
The part of each page is:
<%# Page language="c#" Codebehind="AdvancedPageInheritance.aspx.cs" AutoEventWireup="true" Inherits="PageInheritanceSample.AdvancedPageInheritance" %>
Anything after that first line is part of the body.
If I drag and drop controls onto the form, VS2012 emits code such as:
<asp:CheckBox ID="CheckBox2" runat="server" OnCheckedChanged="CheckBox1_CheckedChanged" />
<asp:Button ID="Button2" runat="server" Text="Button" />
VS2012 automagically emits the warning, "Unrecognized tag prefix or device filter 'asp'."
One thought is to simply add in the body stuff programatically, but that is a page. I rather use the GUI.
How can I avoid the warning? Is there a better way to do templates? That author wrote the article 10-years ago, so things might have changed since then. The warnings are understandable, but in error, as there is a form, body, and html tags, just not directly visible.
(I just answered my question by catching a phrase in Vs2012 and researching it a bit. Master Pages are the answer. Obviously, Microsoft must have added that with either VS2008 or VS2010. I will leave this post, as others, like me, may not know the concept "Master Page" and may reserach page templates, just like I did. I hope that this post says other people time. Google should hopefully pick up on ASP.Net and Page Templates.)
Ideally you would use the MasterPage for laying out your main template.
Your Content pages would then have the appropriate <asp:Content /> controls, where you add your content. To add a content page you would add a new 'Web Form' item in Visual Studio and, by selecting the 'Select Master Page' checkbox, you can choose the master page the content page should use.
See Here for a tutorial on Master Pages
Then you would use a BasePage for site-wide code; for example anything that has logic needed on most pages. Your Content pages would inherit this BasePage
As a side-note, see this page Unrecognized tag prefix or device filter 'asp' in VS2012 with regards to your "Unrecognized tag prefix or device filter 'asp'." message

Is this asp compiled somehow?

I have an aspx document (I know nothing about asp, .net, aspx, nada). It is a normal html table structure for the most part, but there are strings of asp that seem to be inserting some sort of dynamic content. They are in the form:
<asp:Image ID="imgTopImage" runat="server" ImageUrl="~/Images/topbar.jpg" />
<asp:Label ID="lblStyleCaption" runat="server" CssClass="label_caption" Text="Theme: " Visible="false" />
<asp:DropDownList ID="dropStyles" Width="150" runat="server" AutoPostBack="true" />
It seems that whenever I delete one of these——something as innocuous as, say, the line with the asp:Image tag, which I would think should just remove the image, when I load the page I get run-time errors. It's very particular. My question is, is this compiled somehow, which is making it so fragile. Even just changing the topbar.jpg to something.png gives me an error. Do I need to track down the original files this was compiled from, or is this normal server-side asp(x?) that I'm just somehow else goofing up my changes to?
ASPX pages are compiled, and those tags refer to objects that are known to the server, so removing them could cause errors.
First, some basics in layman's terms
Tags that begin with ASP: (Example, <ASP:Button id="btnSubmit" runat="Server" Text="Click Me" />)
are not standard html buttons. They are server controls. When generating the html that goes out to the browser, the ASP.NET runtime looks at the server controls and creates the appropriate content depending on the browser visiting the page.
In the case of the Button control, it's usually a standard html button, but the runtime also generates the JavaScript and such to handle the button's server-side click event.
Why you're probably seeing errors when you remove a control:
Quite often, there's server-side code that's written that accesses these controls. For example, the developer may have decided to change the Text or the Visible property due to some event.
If this is the case, and you remove the <asp:Button> tag, then there will be server-side code that references an object that no longer exists in the aspx page, hence the errors.
More at these links on Server Controls:
http://www.w3schools.com/aspnet/aspnet_controls.asp
(Actually, this older one is better for a new-to-asp.net developer: http://msdn.microsoft.com/en-us/library/zsyt68f1(VS.71).aspx
http://support.microsoft.com/kb/306459
I'd also recommend taking some time watching basic videos or going through the tutorials at http://www.asp.net/get-started
I just noticed this in your question:
Even just changing the topbar.jpg to something.png gives me an error.
That is a bit odd, but I know of at least one way it could happen...
Generally, Visual Studio will give you a warning (and not an error) if you include a relative URL to an image or a linked page that doesn't exist. The warning shouldn't block you from compiling. However, Visual Studio does have a setting that tells it to treat warnings as errors. That will block it from compiling. Here's how that would be set up:
from Project Settings> Configuration Properties select the build
setting and change the “treat warnings as errors” settings to true.
If you wish to NOT treat warnings as errors, simply change the setting to false.

Element <element> is not a known element warning in Visual Studio when using User controls

I have a Visual Studio 2008 project that is showing the following warning when using User Controls, and I haven’t been able to find a solution anywhere.
Element <element>is not a known element
How can I fix this?
This sounds like a classic re-build your solution and "close and re-open Visual Studio" problem.
It's possible it may also be related to a similar problem I had which I answered at Resolving "Validation (): Element ‘xxxx’ is not supported" warning in Visual Studio 2005/2008.
This can also occur if the element you're trying to add is within the tags of another element that it shouldn't be within.
For Example:
<asp:Button ID="button" runat="server" >
<asp:Repeater ID="repeater" runat="server"></asp:Repeater>
</asp:Button>
Or in my case, placing an <asp:Repeater> in an <asp:UpdatePanel> and forgetting to put it in the <ContentTemplate>:
<asp:UpdatePanel ID="upPanel" runat="server">
<ContentTemplate>
<asp:Repeater ID="rep" runat="server">
</asp:Repeater>
</ContentTemplate>
</asp:UpdatePanel>
Apparently this can also happen if the Namespace name in the .ascx file doesn't match the namespace in the ascx.cs (codebehind) file. Just one more issue to check.
From the OP:
The apparent solution to this is to make sure that the TagName is the
name of control class.
So for my example, the following displayed the warning:
<%# Register Src="~/path/to/Control.ascx" TagName="tagName" TagPrefix="tagprefix" %>
<tagprefix:tagName runat="server" id="controlID" />
But changing it to:
<%# Register Src="~/path/to/Control.ascx" TagName="Control" TagPrefix="tagprefix" %>
<tagprefix:Control runat="server" id="controlID" />
fixes it.
Check you might be on ContentPlaceHolderID="MainContent" on Asp.net, so place the code on a new placeholder
This can happen if something's missing in your web.config too. I just ran into this error while copying a custom control from one solution to another, and the page still couldn't find the element. If none of the above fixes the problem, check this section of the web.config and make sure your control is included:
<controls>
<add tagPrefix="fu" namespace="Fubar.Base" assembly="Fubar" />
...
</controls>
After adding this, and then closing/reopening the solution, the problem went away.
I found that the issur was resolved when I changed the Build Action from "content" to "compile" for the .ascx file and afterwards chaned it back.
This can happen when Visual Studio has problems loading assemblies that exist in the web.config file.
Take a look at your web.config file and make sure that all <dependentAssembly> tags have a valid assemblyIdentity value.
Take a look at the output window and make sure that there are no error or warning about dependencies, such as:
Could not load file or assembly 'System.Something.Doesnt.Exist, Version=... or one of its dependencies. The located assembly's
manifest definition does not match the assembly reference.
Remove unnecessary or corrupted values and rebuild your solution.

Resources