Remove last semicolon from a string.

Remove last semicolon,comma from a string.

Hello,

Sometimes we need to remove last comma,semicolumn extra from a
string.

Below is simple way to do this.

text = text.TrimEnd(',');

This is better way instead of Substring option.




Posted in | 0 comments

Alter Message box from code Behind in C# Asp.Net

Alter Message Box from Code Behind


Response.Write(@"<script language='javascript'>alert('The following errors have occurred:" + ErrorDesc + ".');</script>");

Now if you want error message in secondLine.
here the trick.

Response.Write(@"<script language='javascript'>alert('The following errors have occurred: \n" + ErrorDesc + " .');</script>");

or you can double escape the \n by doing 

Response.Write(@"<script language='javascript'>alert('The following errors have occurred: \\n" + ErrorDesc + " .');</script>");

Posted in | 0 comments

Unable to copy file "obj\Debug\Project.exe" to "bin\Debug\Project.exe". The process cannot access the file "bin\Debug\Project.exe" because it is being used by another process.

Problem
Unable to copy file "obj\Debug\*.exe" to "bin\Debug\*.exe". The process cannot access the file "bin\Debug\*.exe" because it is being used by another process.


The reason behind this error is Visual Studio locks the file.

if you close your solution and reopen it your project build successfully without error.
But this is not a preferable solution  all the time.

Below is one suggestion to resolve this problem

When the problem occurs, just change the building configuration at the top (if in “Release” to “Debug” and vice versa), build and then change back to previous configuration and build again.

Hope this will help you.

Posted in | 0 comments

AutoEventWireUp


ASP.NET page framework supports an automatic way to associate page events and methods. 
If the AutoEventWireup attribute of the Page directive is set to true. the page framework calls page events automatically, specifically the Page_Init and Page_Load methods. 
In that case, no explicit Handles clause or delegate is needed.

See the below declration. this should be create when we create new page.
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="test.aspx.vb" 

The disadvantage of the AutoEventWireup attribute is that it requires that the page event handlers have specific, 
predictable names. This limits your flexibility in how you name your event handlers. 
Therefore, in Visual Studio, the AutoEventWireup attribute is set to false by default and the 
designer generates explicit code to bind page events to methods.

If you do set AutoEventWireup to true, Visual Studio will generate code to bind the events 
and the page framework will automatically call events based on their names. 
This can result in the same event code being called twice when the page runs. 
As a consequence, you should always leave AutoEventWireup set to false when working in Visual Studio.

More details : http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbconWebFormsEventModel.asp


Below is another way for explanation of AutoEventWireUp

If you know VB then remeber what happens if you double click on a button in "desing time" in the code an event procedure 

Button_click( ) would come up for you to enter the code.

This is a classic feature of Auto event wireup - and in VB you had to live with it.

But in .NET you can name the event handling function whatever you want and tie up the event with the corresponding handling function.

So if you have a button you could call the MyNewButton_click( ) function. But for this to be possible the "Auto Event Wire-up" property must be set to false at the page level.



Posted in | 0 comments