Using variables in a PageLink property. Need help

Im trying to make use of the pagelink property on a page. What I really want to do is make the value in the PageLink be dynamic. Current, static version: Desired version: But when i use the latter version, i get this error: "Cannot convert type 'string' to 'EPiServer.Core.PageReference'" - What is the easiest and best fix for this..? TIA
Sep 15, 2005 17:50
When using the databinding expression (#), double quotes will always try to convert the result to a string, so internally your code will compile to something like this: propCtrl.PageLink = (string)MyFunction(var); Using single qoutes however will not cast to string: will compile to: propCtrl.PageLink = MyFunction(var); /Steve
Sep 15, 2005 23:36
Using the singlequotes returns the error: "Cannot convert type 'string' to 'EPiServer.Core.PageReference'" Which is why im unsure what is going on. I mean, the function i call will simply sends back a useful value. But somehow the property cannot interprete it. :-/
Sep 16, 2005 10:36
This is the codebehind part of what I am trying to do: public PageReference DisplayRandomSlide(int ParentID) { PageReference SlideShowContent = new PageReference((int) MyPageIDIntegerValue); return SlideShowContent; } Im calling this in my aspx page like so: However it is not returning anything at all. The problem is in the PageReference part. Can anyone help or tell me a better way to make the PageLink eat my integer values..? TIA
Sep 16, 2005 14:45
Your code looks ok to me, as long as you remember to DataBind the page (or more correctly, the control). Using Single quotes should not give you the cannot convert to string exception as long as you use # and not = in your assignment. Try giving the property control an id, and set the PageLink property directly from code behind. That should work. /Steve
Sep 16, 2005 16:32
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.