Setting PageGroup throws error on refresh
Windows Server Forum Index Windows Server
Server discussion on Windows platform.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web winserverhelp.com
Setting PageGroup throws error on refresh

 
Post new topic   Reply to topic    Windows Server Forum Index -> Commerce Server
Author Message
BeerBoy
Guest





Posted: Thu Sep 29, 2005 8:51 pm    Post subject: Setting PageGroup throws error on refresh Reply with quote

I have a page which displays a banner ad using the 'PageGroup'
functionality. All works, except when you hit the browser 'refresh'
button (or when a Postback is performed !). Anyway, the line which sets
the PageGroup fails i.e this line :

csContext.TargetingSystem.TargetingContextProfile["PageGroup"].Value =
"Sports";


Thinking I was doing something wrong I tried the example from the
documentation (attached at bottom of this mail) and it too fails for
the same reason on the second click of the button.

I'm totally stuck on this - any ideas are more than welcome.

Regards

Jim

Cut and paste from :
mk:@MSITStore:D:\Program%20Files\Microsoft%20Commerce%20Server%202002\Documentation\Commerce_Server.chm::/htm/cs_net_examplestargeting_nakz.htm


<%@ Import Namespace="Microsoft.CommerceServer.Runtime.Profiles" %>
<%@ Import Namespace="Microsoft.CommerceServer.Runtime.Caching" %>
<%@ Import Namespace="Microsoft.CommerceServer.Runtime.Targeting" %>
<%@ Import Namespace="Microsoft.CommerceServer.Runtime.Pipelines" %>
<%@ Import Namespace="Microsoft.CommerceServer.Runtime.Diagnostics" %>

<HTML>
<HEAD>
<script language="C#" runat="server">

public void ShowAds_OnClick(Object sender, EventArgs args)
{
CommerceContext csContext = CommerceContext.Current;
//
// Create a targeting profile.
//

csContext.TargetingSystem.TargetingContextProfile["PageGroup"].Value =
"Sports";
//
// Create a user profile
//
Guid guid = Guid.NewGuid();
Profile userProfile =
csContext.ProfileSystem.CreateProfile
(

guid.ToString(),

"UserObject"
);
//
// Get a ContentSelector and set its properties
//
ContentSelector cso =
csContext.TargetingSystem.SelectionContexts["advertising"].GetSelector();

cso.Profiles.Add("targetingContext",
csContext.TargetingSystem.TargetingContextProfile);
cso.Profiles.Add("user", userProfile);
cso.TraceMode = true;
cso.ItemsRequested = 2;
cso.Size = "Half";
//
// Get some content
//
StringCollection content = cso.GetContent();
//
// Bind the results to a repeater
//
if (content.Count > 0)
{
repeaterShowAds.DataSource = content;
repeaterShowAds.DataBind();
}
//
// Dump out Trace Messages
//
if (cso.TraceMessages != null)
{
csContext.DebugContext.Trace("Targeting Sample",
"Trace Messages");
int index = 0;
foreach (StringCollection messages in
cso.TraceMessages)
{
csContext.DebugContext.Trace("Targeting
Sample", "Content item row index=" + index++);
foreach (string message in messages)
{
csContext.DebugContext.Trace("Targeting
Sample", message);
}
}
if (index == 0)
{
csContext.DebugContext.Trace("Targeting Sample",
"It looks like there were no ads on schedule");
}
}
else
{
csContext.DebugContext.Trace("Targeting Sample",
"ContentSelection tracing is unavailable.");
}
csContext.DebugContext.Trace("Targeting Sample",
"Dumping out contents of selectionContext...");
ContentSelectionContext selectionContext =
csContext.TargetingSystem.SelectionContexts["advertising"];
foreach (string key in selectionContext)
{
csContext.DebugContext.Trace("Targeting Sample",
"key=" + key + " value=" + selectionContext[key].ToString());
}
}
</script>
</HEAD>
<body>
<form ID="Targeting" method="post" runat="server">
<h3 id="H31" align="left" runat="server">
Display an advertisement targeting the UserObject and
TargetingContext
profiles.</h3>
<H4 class="dtH4">You should create an ad with a Target
Group associated with the <B>Sports</B>
page group before running this example.&nbsp;</H4>
<P class="dtH4">
<asp:Button id="ButtonShowAds" Text="Show Sports Ads"
runat="server" OnClick="ShowAds_OnClick" /></P>
<P class="dtH4">
<asp:Repeater id="repeaterShowAds" runat="server">
<HeaderTemplate>
<table border="1">
<tr>
<td><b>Sports Ads</b></td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<%# Container.DataItem %>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</TABLE>
</FooterTemplate>
</asp:Repeater></P>
</form>
</body>
</HTML>
Back to top
BeerBoy
Guest





Posted: Wed Oct 19, 2005 8:51 am    Post subject: Re: Setting PageGroup throws error on refresh Reply with quote

Fixed it !!!!

It seems that the Targeting Conrtext profile was set up such that the
'Page Group' property was a key !!!

I simply created a new key property, took the key dependancy off od
'Page Group' and everything worked.
Back to top
 
Post new topic   Reply to topic    Windows Server Forum Index -> Commerce Server All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




New Topics Powered by phpBB