Code Project

Link Unit

Tuesday, May 19, 2009

Tip to optimize C# Refactoring in Web Projects

I usally do the refactoring of the web application code developed over period of time to make it more managable. But most of the time VS take too long that it becomes better to do refactoring on your own.Later I decided to read some blog posts to see whether someone has work on Optimising Refactor. After googling around for a while, I found the solution.

Scott has posted a great tip for speeding up refactoring performance with Web Projects in VS 2005.

Solution:

  1. Click Start->Run in Windows and run "regedit"
  2. Navigate to this registry location: HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\8.0\CSharp\Options\Editor
  3. Right-click on the Editor node and choose "New DWORD value"
  4. Name the value "OpenAllVenusFilesOnRefactor" and leave the value as 0

Then, when you restart VS 2005 and perform a re-factoring - you should find performance very fast.

 

This hack basically turns off the refactoring functionality beyond the current page and so it's pretty fast. It looks like this has been fixed in Visual Studio 2008 thankfully.


Hope it Helps
Jatinder

Monday, May 11, 2009

JavaScript : Convert Ok/Cancel into Yes/No

Just came across a post, brilliant way to change the confirm box from ok n cancel to yes n no

 

Found the info on the link http://www.delphifaq.com/faq/javascript/f1172.shtml

 

Here is the code:

 

<script language=javascript>

 

/*@cc_on @*/

/*@if (@_win32 && @_jscript_version>=5)

 

function window.confirm(str)

{

    execScript('n = msgbox("'+str+'","4132")', "vbscript");

    return(n == 6);

}

 

@end @*/

</script>

 

Hope visitors find it useful.

Tuesday, April 28, 2009

How to Solve Method Error 500 - Maximum Length Exceeded with AJAX web service call

At client side I've been assigned a bug concerning
a combo box. When the combo box is changed by the
user, a secondary combo box has its values reloaded.
This is done by calling a web service. The bug is
that "Method Error 500" is displayed as the only
item on occasion. I checked and cross checked the
problem with my own post
http://jatindersingh.blogspot.com/2008/03/method-error-12030.html  ,
but could not sort the error , search on google lead to
the following solution.
 
Solution:
After some rooting around, it turns out that this is
caused by too much data being returned in the SQL query
behind the web service call, so the web service returns
an error. A simple change to the web.config file can
increase the size limit of data returned:
 
<system.web.extensions>
  <scripting>
    <webServices>
       <jsonSerialization maxJsonLength="5000000" />
    </webServices>
  </scripting>
</system.web.extensions>
 
Explaination:
First off, the serialization process will fail if the
number of nested objects is greater than that defined
within the RecursionLimit property , which is 100.
The serialization process will also fail if the length
of the serialized text is greater than that of the
MaxJsonLength property; again, note the default value
of 2,097,152 base ten.
Source http://www.codeproject.com/KB/ajax/ajax_json_serialization.aspx 

Hope visitor find it useful.

Wednesday, April 15, 2009

string.Empty Example and Issues in C# written by Sam Allen

string.Empty Example and Issues in C# written by Sam Allen

Problem. You are wondering how to use string.Empty and how it is different from an empty string literal constant "". There is a subtle different, and it can be significant in some scenarios, in that it changes the meaning of your program. Solution. Here we see how to use string.Empty, and then look into its implementation, finally seeing an example of how it can produce less effective code.

For more information click here  http://dotnetperls.com/Content/string-Empty.aspx

Tuesday, April 14, 2009

Crystal Reports Toolbar Images Displaying as Red X

Recently we developed reports for our web application in crystal report, but we faced the problem of toolbar images displaying as red X. On development machine it worked perfectly but on Production Server it failed to display.

Solution:

Copy aspnet_client folder from your PC and paste it in application folder on server ,then refresh the IIS default website and its done. It solved the problem for me I hope it help visitors too.

Sunday, March 29, 2009

Provider error '8007000e' , Not enough storage is available to complete this operation

Problem :
I was facing "Provider error '8007000e' , Not enough storage is available to
complete this operation." error in vbscript of an classic asp application.

code was as below-

set rsGetEnquiryInfo = server.CreateObject("Adodb.Recordset")
rsGetEnquiryInfo.Open strSql,conn,3,1
dim intFieldCount, intCounter
if not((rsGetEnquiryInfo.BOF) and (rsGetEnquiryInfo.EOF)) then
intFieldCount = rsGetEnquiryInfo.GetRows() '--- getting error at this line
end if

Solution:
MDAC version should be 2.8 +
The version information is found in the following key:
HKEY_LOCAL_MACHINE\Software\Microsoft\DataAccess\FullInstallVer
To check the registry, follow these steps:
• On the Start menu, click Run.
• In the Open text box, type regedit and then click OK; this starts Registry Editor.
In the Navigation pane, drill-down to the following path:
HKEY_LOCAL_MACHINE\Software\Microsoft\DataAccess
• In the Details pane, look in the Name column for FullInstallVer and Version. Each of these keys will have corresponding version information in the Data column.
• When finished, click Exit on the Registry menu to close Registry Editor.

Setting the rsGetEnquiryInfo object to nothing should solve the error.

Wednesday, March 11, 2009

ValidationSummary displayed multiple times in UpdatePanel

While working on a ASP.Net Web Application , we faced a peculiar situation where the validationsummary is displayed many times. Googled around a bit for the solution and this is what I found , I hope this help visitors also.


Asp.net comes is really good with the Validation Controls. For example the RequiredFieldValidator is perfectly suited because it displays a little error message for the control it validates.

All is fine until you have 40-50 fields that have to be filled out. In this case it's of good practice to use the ValidatioSummary control which summarises all the error messages from the ValidationGroup and shows them either in text on the page or as a Javascript alert().

All is fine until you use the ValidationSummary inside an UpdatePanel, where something rather interesting happens. The alert box is displayed multiple times. When I got this behaviour it was even more interesting that the number of times the alert box is displayed was not constant.

But there is a correlation between the number of times the alert is displayed and the number of asynchronous postbacks in that UpdatePanel. The ValidationSummary alert() is displayed exactly the number of asychronous postbacks times plus one.
0 postbacks --> 1 alert
2 postbacks ---> 3 alerts

Solution
To avoid this behaviour you only have to place the ValidationSummary outside the UpdatePanel, this will prevent it from reregistering itself for validation on each asynchronous postback.