Code Project

Link Unit

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.

Thursday, February 19, 2009

ObjectDataSource: could not find a non-generic method '...'

I found this can help:
Change:
OldValuesParameterFormatString="original_{0}"
to
OldValuesParameterFormatString="{0}"

But in most of my cases the following helped

A “Bind” was added accidently to a hidden Field, and it started showing as input parameter to the Insert /Update Method because of 2 way Binding. I went to the aspx and changed those "extra" fields to say "Eval" instead of "Bind" and it all started working again.

Saturday, December 13, 2008

AJAX Error: 'Sys' is undefined

The error means that you're not getting the client side files loaded on your browser

So I ran fiddler to see what is happening and which file is not getting download.

After struggling to solve the error , this is what saved the day for me.

Web.Config: Make sure your web.config is correctly configured to handle AJAX enabled request. You might have created a project which was not AJAX enabled earlier and now you want to Ajaxfy. The best solution is creating a new project ASP.NET AJAX Enabled Web Site. It will create a Web.config file by default.

Or You can change Web.Config to add following

<add verb="GET"
path="ScriptResource.axd"
type="Microsoft.Web.Handlers.ScriptResourceHandler"
validate="false"/>

Wednesday, September 24, 2008

"Page Cannot be found" when browsing aspx pages in Windows 2003

"Page Cannot be found" when browsing aspx pages in Windows 2003

One of my colleague was facing the issue . This is how we resolved it. Hope it helps you also.
You may get a Page cannot be found message when you browse aspx pages in a Windows Server 2003 environment.

That is because in Windows 2003, all the webservice extensions are "Prohibited" by default to ensure security.

To resolve this, do the following steps:-

Step A)
Click on start then select Run. Copy and paste this command then click okay. That will reregister ASP.NET to IIS 
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -i

Step B)
1. From your Run command, type inetmgr and press enter.
2. Expand the appropriate nodes in the IIS to locate the "Webservice Extensions" Node
3. Click on the same.
4. You will find a list of "prohibited" extensions in the right.
5. Click on ASP.NET and "allow" it

That should resolve this issue.

 

Friday, June 27, 2008

An attempt to attach an auto-named database for file failed. A database with the same name exists, or specified file cannot be opened, or it is locate

I was implementing the sample given at this site http://www.beansoftware.com/ASP.NET-Tutorials/Web-Parts.aspx and encountered the issue.
An attempt to attach an auto-named database for file c:\.....\App_Data\aspnetdb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
The solution for which is as follows:
we have to add following few lines to the web.config file as below:

"User Instance=True;"
Once I added this option to the Connection String everything works fine. So the new connectionstrings look like this.

<connectionstrings>
<remove name="LocalSqlServer">
<add name="LocalSqlServer" providername="System.Data.SqlClient" connectionstring="Data Source=.\SQLEXPRESS;AttachDbFilename=DataDirectory\ASPNETDB.MDF;user instance=true;Integrated Security=True;Initial Catalog=ASPNETDB;">
</connectionstrings>

I hope this helps the visitors.

Tuesday, June 03, 2008

Using DBMS_METADATA.GET_DDL to generate the table script

I was using Oracle 10g where it required to get the Scripts of all the tables.
While searching google I ended up with DBMS_METADATA.GET_DDL

SELECT DBMS_METADATA.GET_DDL ('TABLE',tname)';' FROM tab where tabtype='TABLE'

I hope this help the visitors.

Monday, May 19, 2008

ASP.Net Server Unable to assign port

I was facing this problem(ASP.Net Server Unable to assign port) way back when I started using Visual Studio . After googling around for a while this is what solved the issue for me.
I hope this help you as well.
If you want to assign a fixed port number for debugging, please refer to the following steps:
1. Right click the Project in the Solution Explorer, and then select “Properties” 2. Click “Web” tab. 3. Check “Specific port” instead of “Auto-assign Port”.
If you want to debug with IIS, please follow the first and second steps above, and then check “Use IIS Web Server” instead of “Use Visual Studio Development Server”. Also, click the “Create Virtual Directory” button.
Please note the above steps are based on Web Application project. For the Web Site project, we can fix the port number by following steps:
1. Click the project in Solution Explorer. 2. Open “Properties” panel. 3. Set “Use dynamic ports” property to false and assign a value to "Port number".
You may also like to follow the excellent description given at following link
http://blogs.msdn.com/bradleyb/archive/2005/08/29/457573.aspx
I hope this help you as well.