by lichen
1/30/2006 8:01:00 PM
This post by Fredrik Normén is a big help. I need to create a custom parameter that binds to Context. I was able to create in minutes following the example. The result is:
public class ContextParameter : System.Web.UI.WebControls.Parameter
{
private string _contextField;
public ContextParameter()
{
}
protected ContextParameter(ContextParameter original)
: base(original)
{
this.ContextField = original.ContextField;
}
protected override object Evaluate(HttpContext context, Control control)
{
if (context != null && _contextField != null)
{
return context.Items[_contextField];
}
else
{
return null;
}
}
protected override Parameter Clone()
{
return new ContextParameter(this);
}
public string ContextField
{
get
{
return _contextField;
}
set
{
_contextField = value;
}
}
}I can the use the parameter like:
<dt:ContextParameter Name="PageID" ContextField="PageID" Type="String" DefaultValue="136b08ff-3752-4704-8db8-cf323a98bfaa" />
by lichen
1/30/2006 4:23:00 PM
Many CMS uses friendly paths and the RewritePath method to rewrite a friendly path to a more cryptic path that contains a query string. A common problem is that the web form is then posted to the cryptic path rather the user friendly path. A workaround can be found at this post.
The solution is to call RewritePath again in the OnLoad event. In CMS, it is quite typical that all pages are inherited from a custom base class derived from the Page class. We can override the custom base class to call RewritePath again, like:
Context.RewritePath(path,
null, query);
Note that it is important to pass “” to query parameter if there is no query string. It will not behave correctly if we pass null.
by lichen
1/30/2006 9:24:00 AM
Jeff Prosise has a nice article on MSDN magazine about SqlSiteMapProvider. The provider is an update to the SqlSiteMapProvider in Microsoft Provider Toolkit which was authorized by the same author.
After using the provider in my website, I found that I have to change a few things:
- Changed the stored procedures to use Common Table Expression so that records where sorted in order even if they were populated out of order.
- Use the URL as key. The reason is that otherwise the items on a menu control that corresponds to the current page would not appear to be automatically selected. An alternative way to work around this problem is in this Danny Chen's blog.
- The SqlSiteMapProvider does not allow external URLs but the XmlSiteMapProvider does allow external URLs. The fault was really in StaticSiteMapProvider from which SqlSiteMapProvider was inherited from. The XmlSiteMapProvider overrides the AddNode method of StaticSiteMapProvider. Since the AddNode method was declared as internal override, we cannot override it. A workaround is to use an internal redirect page to redirect to an external URL.
by lichen
1/8/2006 8:57:00 PM
Visual Studio.Net does not know the path to an assembly referenced when opening a project file? It is possible to tell Visual Studio.Net the path of an assembly by adding a key at HKLM\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders.
For example,
HKLM\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders\NUnit.Framework
The default value should point to the path of assemblies.
Be the first to rate this post
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5
Tags:
.Net