Problem:
You want to use <label> to point to fields in your ASP.NET controls, but due to HTML ID mangling, you cannot.
Solution:
Walk the control tree on load and update the "for" attribute on the <label>.
For example, let's say you have the following code in your control:
<label for="UserName">User Name</label>
<asp:textbox id="UserName" runat="server" columns="30">
First, add runat="server" and an ID to your <label> like so:
<label ID="UserNameLabel" for="UserName" runat="server">
User Name</label>
<asp:textbox id="UserName" runat="server" columns="30">
The ID keeps Visual Studio happy.
Then, in your Page_Load(), call the following helper function:
private void UpdateLabelsWithClientID(Control c)
{
foreach (Control c1 in c.Controls) UpdateLabelsWithClientID(c1);
if (c is HtmlGenericControl && ((HtmlGenericControl)c).TagName == "label")
{
string controlName = ((HtmlGenericControl)c).Attributes["for"];
Control c2 = this.FindControl(controlName);
if (c2 != null) ((HtmlGenericControl)c).Attributes["for"] = c2.ClientID;
}
}
If you are in an ASP.NET control, you would call it as UpdateLabelsWithClientID(this);.
February 11, 2009
February 7, 2009
SiN 1 in SiN: Episodes
Before we started working on SiN: Episodes, one of the things we started working on to properly learn Source was a Source engine version of the original SiN ala Half-Life: Source. A lot of the work was done by Dale Broadbent.
It didn't get very far and barely functions, but there's enough here that some Source engine modders might get a kick out of it.
What is here requires S:E1 to work. Use at your own risk. No warranties are expressed or implied.
http://hosted.romsteady.net/S1inSE.zip (64.8MB)
It didn't get very far and barely functions, but there's enough here that some Source engine modders might get a kick out of it.
What is here requires S:E1 to work. Use at your own risk. No warranties are expressed or implied.
http://hosted.romsteady.net/S1inSE.zip (64.8MB)
February 6, 2009
January 12, 2009
Sitefinity: Clean Up Search Results
Problem:
You are using Sitefinity 3.x and your page templates and other non-desirable parts of the pages are showing up in search results.
Reason:
Sitefinity spiders your site instead of searching the data. For the most part, this is a good thing, but it pollutes your search data.
Workaround:
Sitefinity gives us the tools to hide the template from the search spider, but they are rather hidden. To use this workaround, I am going to work under the assumption that all of your templates have a standardized naming scheme for their ContentPlaceHolder objects. For example, all of my pages have the main content in a ContentPlaceHolder named "Content," my sidebar is in a ContentPlaceHolder named "SideBarContent," and so on.
First, create a new master page that is empty except for the ContentPlaceHolder objects you want included in the search results and the header tag ContentPlaceHolder. Since I only want what is in my primary content area to appear in the search results, I have one ContentPlaceHolder in my body named "Content." Upload this into Sitefinity.
Second, if you do not have an App_Code folder in your Sitefinity project, add one to the project root.
Third, create a BasePage class. This class will inherit from InternalPage. Override the OnPreInit() function and drop in the following code...
...where SearchOverrideMasterPage.master is the name of the new master page you want to uploaded in step one.
Fourth, go into the Sitefinity folder and edit cmsentrypoint.aspx. Change...
...to be...
...where ClassNameOfBaseClass is the name of the class you created in Step 3.
Fifth, go into your App_Data/Search folder and delete the folders contained therein to delete the current search indices and results.
Finally, go into Sitefinity's Administration tab and under Services / Search, click "Start indexing" under each search index.
You are using Sitefinity 3.x and your page templates and other non-desirable parts of the pages are showing up in search results.
Reason:
Sitefinity spiders your site instead of searching the data. For the most part, this is a good thing, but it pollutes your search data.
Workaround:
Sitefinity gives us the tools to hide the template from the search spider, but they are rather hidden. To use this workaround, I am going to work under the assumption that all of your templates have a standardized naming scheme for their ContentPlaceHolder objects. For example, all of my pages have the main content in a ContentPlaceHolder named "Content," my sidebar is in a ContentPlaceHolder named "SideBarContent," and so on.
First, create a new master page that is empty except for the ContentPlaceHolder objects you want included in the search results and the header tag ContentPlaceHolder. Since I only want what is in my primary content area to appear in the search results, I have one ContentPlaceHolder in my body named "Content." Upload this into Sitefinity.
Second, if you do not have an App_Code folder in your Sitefinity project, add one to the project root.
Third, create a BasePage class. This class will inherit from InternalPage. Override the OnPreInit() function and drop in the following code...
base.OnPreInit(e);
if (CmsContext.IsCrawlerRequest)
{
this.MasterPageFile = "~/App_Master/SearchOverrideMasterPage.master";
}
...where SearchOverrideMasterPage.master is the name of the new master page you want to uploaded in step one.
Fourth, go into the Sitefinity folder and edit cmsentrypoint.aspx. Change...
Inherits="Telerik.Cms.Web.InternalPage"...to be...
Inherits="ClassNameOfBaseClass"...where ClassNameOfBaseClass is the name of the class you created in Step 3.
Fifth, go into your App_Data/Search folder and delete the folders contained therein to delete the current search indices and results.
Finally, go into Sitefinity's Administration tab and under Services / Search, click "Start indexing" under each search index.
January 8, 2009
Sitefinity: Making a Custom Site Map
As part of a redesign of our current website at work, we're going to be changing to Sitefinity for our CMS.
The only downside is that working sans JavaScript is still a fairly big requirement for us and some of the built-in controls rely on JavaScript to function.
So...I'm rewriting some of the controls.
Here is a simple sitemap control that works with Sitefinity. Control is written in VB.NET, set up for CSS styling, and is free for customization as you see fit.
SiteMapControl.zip (1,150 bytes)
The only downside is that working sans JavaScript is still a fairly big requirement for us and some of the built-in controls rely on JavaScript to function.
So...I'm rewriting some of the controls.
Here is a simple sitemap control that works with Sitefinity. Control is written in VB.NET, set up for CSS styling, and is free for customization as you see fit.
SiteMapControl.zip (1,150 bytes)
Subscribe to:
Posts (Atom)