Friday, September 19, 2008

Cannot create/shadow copy <your assembly file> when that file already exists

Cannot create/shadow copy < your assembly file dll > when that file already exists

When you compile the web projects in visual studio 2005/2008, you may receive the above message. 
And in order to get rid of this, you can either kill the process aspnet_wp.exe using the task manager 
or add the following tag in the web.config inside system.web tag.

<hostingEnvironment shadowCopyBinAssemblies="false" />

Although the former resolution is just a temperory fix, the later one will fix this issue for that 
project permanantly.

-::-

Monday, September 15, 2008

Javascript to limit characters (length) in Text Area or Multiline TextBox

Bind the below function to keypress event as below

txtJustification.Attributes.Add("onkeypress", "return limitText('" + txtJustification.ClientID + "', 3000);");

function limitText(limitField, limitNum)
{
var obj = document.getElementById(limitField);
if (obj.value.length > limitNum){return false;} else return true;
}

Hope this helps

MDI Child Window always on top - Winforms

As MDI Child winform cannot be shown on top by using "BringToFront" or "TopLevel=true" properties. This could be achieved only by setting the property frm.Owner = frmMDI

Hope this helps

OnClientClick and Form Validation in Asp.net

When we use OnClienClick script for a button in asp.net, you can notice that all the associated validation controls (validation group) will fail to validate. This happens because the OnClientClick script overrides form validation script.

To fix this, here is the work around.Add the below code in Page Load event

Button1.Attributes.Add("onclick", "if(confirm('do this ?') == false) return false;");

This will execute the client script and then executes the form validations scripts before post back.

Hope this helps

Friday, September 05, 2008

ASP.NET Menu control not being rendered properly in Google Chrome

Today i tried installing the Google Chrome in my laptop machine. Although it is light and nice in look and rich in features (as usual from Google), it showed some weired behaviour when i open my online applications. Especially the ASP.Net Menu Control was not rendered as is to be.

It does not display the child nodes on hover and when we click any menu item, it then refresh the page with child nodes...

Cause & Resolution

The reason for this weird behaviour is just because the way the menus are rendered in chrome is different from IE and Fire Fox (FF). The recent chrome browser render the <a> component as <div> and <span> . If you look into the view source, you may notice that the menu structure as below.
<div id="ctl00_mainMenu">
<span><a class="ctl00_mainMenu_1" href="Test1.aspx">Menu1</a></span>
<span><a class="ctl00_mainMenu_1" href="Test2.aspx">Menu2</a></span>
<span><a class="ctl00_mainMenu_1" href="Test3.aspx">Mwnu3</a></span>
</div>
It is because of both Internet Explorer and Firefox render the ASP.NET Menu control as <table>--<a> mark up.
However, the rendered mark up for the latest beta version of Google Chrome will be like the following code, the <table> and <a> become to <div> and <span> :
And the best resolution for the subject issue is to ASP.NET 2.0 CSS Friendly Control Adapters 1.0. This adapter will render the ASP.NET Menu in Google Chrome properly
-::-