Archive for ‘ASP.NET’

February 27, 2012

ASPxNavigationBar – JavaScript when NavBarItem clicked

following code example explains how to execute a java script function when any an items in a ASPXNavbar is clicked.

<dx:ASPxNavBar ID="nbMenuSPISLeedOwners" runat="server" Width="100%" AllowSelectItem="True"
DataSourceID="SiteMapDataSource1" OnItemDataBound="ASPxNavBar1_ItemDataBound">
<ItemStyle HorizontalAlign="Left" />
<GroupHeaderStyle HorizontalAlign="Center">
<ClientSideEvents ItemClick="OnItemClick" />

<dx:ASPxLoadingPanel ID="loadingPanel" runat="server" Text="Redirecting&amp;hellip; Please wait!"
ClientInstanceName="loadingPanel" BackColor="Pink" >

The Javascript should be as follows:

function OnItemClick(s, e) {

February 13, 2012


Was getting the above error at the time of exporting an excel file using the ASPxGridViewExporter. I had a tab control (ASPxPageControl) with some ASPxGridView controls inside all the tab pages. So using the ASPxGridViewExporter when i tried to export an excel file was battered with the following error every time when i tried to export.

Sys.WebForms.PageRequestManagerParserErrorException:  The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled. To sort out the problem you had to register the control which triggers the postback in the page init of the page. The code as follows.

<br />
protected void Page_Init(object sender, EventArgs e)<br />
{<br />
RegisterPostBackControl();<br />
<p>private void RegisterPostBackControl()<br />
{<br />
ScriptManager sm = (ScriptManager)Page.Master.FindControl(&quot;MainScriptManager&quot;);<br />
sm.RegisterPostBackControl(ASPxPageControl1);<br />

please refer the KB article.

PageRequestManagerParserErrorException – what it is and how to avoid it

April 26, 2011

Dev Express v10.1 Compilation Error Message: CS0012

CS0012: The type ‘DevExpress.Utils.IAssignableCollection’ is defined in an assembly that is not referenced. You must add a reference to assembly ‘DevExpress.Data.v10.1, Version=, Culture=neutral, PublicKeyToken=b88d1754d700e49a’.

check your web.conf file whether the said “DevExpress.Data.v10.1, Version=, Culture=neutral, PublicKeyToken=b88d1754d700e49a” entry exists or not. if not just add and recompile. Usually when you add any DevExpress controls to your form Visual Stuido automatically adds the entries as above. if you replaced the web.conf file with another due to so many reasons this used to happen.

March 9, 2007

"Server Error in ‘/application name’ Application"

You may receive the Error Message “Server Error in ‘/application name’ Application” while browsing an application.

You may receive the following error message while browsing an application.

“Server Error in ‘/application name’ Application

Runtime Error Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

Details: To enable the details of this specific error message to be viewable on remote machines, please create a tag within a “web.config” configuration file located in the root directory of the current web application. This tag should then have its “mode” attribute set to “Off”.

This error might occur due to two scenarios.

1. There is an error in the application’s logic with the inputformat, Type etc., and you have set the Custom Error Mode in the web.config to “On” and not specified a default redirect error page.

2. The web.config file is not well formed or having invalid characters and the application is not able to pick up the settings from the same.


1. Set the custom error mode to “Off” to view the error.
After rectifying it and before deployment, change it to “On” and specify a default error page, as follows:-

such that your users will not be able to see the actual error and get your friendly error page where you can politely say “An error has occured! Contact the Application Help Support …” .

2. If the above solution is not working (i.e. even after setting the custom error mode to On, the same “Server Error” occurs, then the likely chance is that your web.config file is not well formed and has invalid characters etc.,

To resolve, it copy paste the contents of the file to a notepad, save it as an xml file and try to browse the xml file in the browser. If the xml file is unable to be rendered by the browser and throws error, then you can find the place where the tags are not well formed or invalid character(s) exist and rectify them.

Things worth noting is Web.config is case sensitive (off, oFF,..etc) and even trailing/leading spaces can cause the above error.

you will encounter the same problem at the time of hosting a website to a remote webserver. Eventhough once you have change the web.conf you will get that above message.

solution is to check whether is to make sure that you have given appropriate/suitable permission to the folders like App_Data & to double check the .NET version.

hope all you guys can learn something about the above problem.


January 24, 2007


Just thought to share my code which i used to implement a simple Mail System. Hope this might help you!

Imports System.Net.Mail

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SendEmail.Click
Dim Msg As MailMessage = New MailMessage()
Dim MailObj As New SmtpClient
Msg.From = New MailAddress(UsersEmail.Text, “Andy”)
Msg.To.Add(New MailAddress(“”, “Author”))
MailObj.Host = “”
MailObj.Port = 25
Msg.IsBodyHtml = “False”
Msg.Body = Body.Text
Msg.Subject = Subject.Text
Label1.Text = “Email Sent!”
Catch ex As Exception
Label1.Text = ex.Message
End Try
End Sub

Add your IP Address (local) in your SMTP server & under the properies add the same IP address to Relay Restrictions (Grant & deny permissions to relay email through this SMTP virutal server).

The sent email will be a spam email!

extra notes on this:

under web.config under

namespace System.Net.Mail;

string UserName = System.Configuration.ConfigurationManager.AppSettings[“smtpUsername”];
string Password = System.Configuration.ConfigurationManager.AppSettings[“smtpPassword”];
string Host = System.Configuration.ConfigurationManager.AppSettings[“smtpServer”]; string sFrom = “”;
string sTo;
string sSubject = “sample subject”;
string sBody = “sample html body“;

string toAddress = “,”;
string msgSubject = sSubject;
string msgBody = sBody;

SmtpClient client = new SmtpClient(Host);
MailAddress from = new MailAddress(sFrom);
MailAddress to = new MailAddress(toAddress);
MailMessage message = new MailMessage(from, to);
message.Priority = MailPriority.High;
message.IsBodyHtml = true;

System.Net.NetworkCredential NTLMAuthentication = new System.Net.NetworkCredential(UserName, Password);
message.Subject = msgSubject;
message.Body = msgBody;
client.UseDefaultCredentials = false;
client.Credentials = NTLMAuthentication;

November 16, 2006

An attempt to attach an auto-named database for file "C:\AAA\database.mdf" failed. A database with the same name exists, or specified file cannot be o

This one of the next headache you have to solve at the time of hosting your application in any web server, and its as follows:

An attempt to attach an auto-named database for file c:\hosting\webhost4life\member\shanti23\aba\LatestABAWebsite\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.

we have to add following few lines to the App.conf file as below:

just refer the link:

alternatively you can rename the database at the time of deploying the web application if any further exception bugged you! hopes this will help you all!

November 16, 2006

Exception Details: System.Data.SqlClient.SqlException: Failed to update database.

i would like to share my experience with you all because when you started working with SQL Server Express 2005 you have to encounter probelms like one of which am i going to explain you in this blog entry: hopes it will helps you to not to search it for the same problem throughout days or months, as i have to search it for the solution for many days!

Exception Details: System.Data.SqlClient.SqlException: Failed to update database “c:\hosting\webhost4life\member\abc23\aba\LatestABAWebsite\App_Data\aspnetdb.mdf” because the database is read-only.

This will happen mainly coz of the folder permission that we have to apply for the App_data folder: so to rectify this problem you have to follow these steps:

After selecting the ‘properties’ on the “App_Data” directory,

1. Select the security tab
2. CLick on Add… under “Group or User names:” table
3. On the next window, select Advanced, another window appears and on this, select or rather click on “find now” and a list of Groups and Users should appear on the bottom table.
4. Click on ASPNET followed by OK, and the same on the next 2 windows.

if you need to enable the security tab in Windows XP Professional you have to uncheck the setting for “Use simple file sharing (recommended)” under the View tab in the Folder Options control panel applet to enable the Security tab to be displayed. after that you can be able to view the security tab when you viewed any folder properties.

November 16, 2006


If you place a file with this name in the root of a web application directory, ASP.NET 2.0 will shuts-down the current web application, unloads the web application from the domain server, and stops processing any new incoming requests for that application.

ASP.NET will also then responds to all requests for dynamic pages in the application by sending back the content of the app_offline.htm file.

For example: you might want to have a “Site is under construction” or “the current website is down for maintenance” or “Uploading Changes” message.

This is one of the convenient & easy way to take down your application while you are making big changes or copying lots of new page functionality (at the same time you can avoid the annoying problem of people hitting and activating your site in the middle of a content update). It can also be a useful way to immediately unlock and unload a SQL Express 2005 database whose .mdf data files are residing in the /app_data directory. This will be applicable for the Access (*.mdb) files too!

Once you have removed the app_offline.htm file from the root, the very next request into the web application will cause ASP.NET to load the application and application domain again, and life will continue along as normal.

February 28, 2006

How to send e-mail programmatically with System.Web.Mail and Visual Basic .NET

This article demonstrates how to use System.Web.Mail to send an e-mail message in Visual Basic .NET.

1.Start Microsoft Visual Studio .NET. On the File menu, click New and then click Project. Click Visual Basic Projects, click the Console Application template, and then click OK. By default, Module1.vb is created.

2.Add a reference to System.Web.dll. To do this, follow these steps:

a.On the Project menu, click Add Reference.
b.On the .NET tab, locate System.Web.dll, and then click Select.
c.Click OK in the Add References dialog box to accept your selections. If you receive a prompt to generate wrappers for the libraries you selected, click Yes.

3.In the code window, replace the whole code with:Imports System.Web.Mail

Module Module1
Sub Main()
Dim oMsg As MailMessage = New MailMessage()
‘ TODO: Replace with sender e-mail address.
oMsg.From = “”
‘ TODO: Replace with recipient e-mail address.
oMsg.To = “”
oMsg.Subject = “Send using Web Mail”
‘ SEND IN HTML FORMAT (comment this line to send plain text).
oMsg.BodyFormat = MailFormat.Html
‘HTML Body (remove HTML tags for plain text).
oMsg.Body = “‘Hello World!‘” ‘ you can use html tags here to edit your texts as you wish
‘ TODO: Replace with path to attachment.
Dim sFile As String = “C:\temp\Hello.txt”
Dim oAttch As MailAttachment = New MailAttachment(sFile, MailEncoding.Base64)
‘ TODO: Replace with the name of your remote SMTP server.
SmtpMail.SmtpServer = “MySMTPServer”
oMsg = Nothing
oAttch = Nothing
End Sub
End Module

4.Modify code where you see “TODO”.
5.Press F5 to build and run the program.
6.Verify that the e-mail message has been sent and received.