Monday, March 17, 2008

Migrating to VS2005 Web Application Project Problems

When I was trying to migrate to my VS2005 Web Site Project to VS2005 Web Application Project, I had a weird problem. I had one user control that uses asp.net ajax and a page that uses this control. While the control itself succeeded in Converto To Web Application operation (from the context menu of the project), the page did not. What solved the problem was adding a Register directive to the page (just for generating the designer file) and removing it after that:

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>

Another thing that took me some time was that I had to change manually the Build Action for all my files from App_Code from Content to Compile.

More for migrating from vs2005 web site project to vs2005 web app project can find here. If you want to migrate vs2003 web project to vs2005 web app project, see here.

How to Access UserControl from shared code in VS2005?

If you use the standard model - web site with App_Code directory, you could access a UserControl if you implement an interface that also belongs to App_Code. This is because asp.net compiles App_Code in one assembly, and the other folders (or every single page/control) in other assemblies. Other ugly way to do this is by using reflection, which I do not recommend. The best way is to migrate to Web Application Project which is very similar to the old good time of VS2003 projects that we all are used to. This goes with service pack 1 of the studio. You get a single assembly and thus all your pages and controls are visible to your utils classes.

Thursday, January 10, 2008

Accessing IFrames

Here is a sample how to access elements in an iframe from the parent document and how to access parent elements from the iframe.

This is how I get the value of the textbox in the iframe from its parent:

document.getElementById('myFrame').contentDocument.getElementById('tbText').value

And this is how I get the value of the textbox in the parent document from the iframe:

parent.top.document.getElementById('tbText').value
eXTReMe Tracker