by Digvijay
30. October 2008 04:20
I spent almost 3 hours today trying to figure out what is wrong with one of the WebControl I am writing. The component reads up a XML file and based on that allows for dynamically populating a Data Entry interface - absolutely no markup in the aspx and all the dynamically created controls can callback/raise events to the container page when some events occur. However i noticed in case of ModalPopupExtender i can not get back any events whatsoever and if i add a update panel it just recreates itself then and there and all the entered data is gone!!!
What was i doing wrong!
As one of my colleague pointed out i should have used INamingContainer on each of the dynamic controls that i was making because they in turn create some dynamic child controls. And as soon as i implement INamingContainer on the base control all worked just fine. Its weird but it works. I guess its time to dig deep in the INamingContainer!!!
public interface IInputControl : INamingContainer
{........
}
Hope someone finds this tip useful.
by Digvijay
15. September 2008 23:19
There is quite a useful feature since ASP.NET 2.0 which I did not observe earlier. I needed it now so here it is:
To be able to add a specific tag prefix and specify namespaces in a central location (web.config) such that it allows for specifying the that ASP.NET runtime can find when we import it an ASPX pages. In ASP.NET 1.x one had to use the intrusive @Import directive:
<%@ import namespace="MyCompany.App.WebControls" %>
However, now in ASP.NET 2.0 one can add default namespaces into the web.Config files as shown below:
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<system.web>
<pages>
<namespaces>
<add namespace ="System.IO" />
<add namespace="MyCompany.App.WebControls"/>
</namespaces>
</pages>
<controls>
<add tagPrefix="mytag"
namespace="MyCompany.App.WebControls"
assembly="MyCompany.App.WebControls" />
</controls>
</system.web>
</configuration>
just this and you can use mytag as a control prefix in your markup, if you are used to writing it by hand rather than drag and drop!
I found it quite handy and I hope you can find a good use for it too!!!