Surendra Sharma

Surendra Sharma

Search This Blog

Friday, June 28, 2013

How to get autoincrement assembly version for ASP.NET website

In ASP.NET, developer can not assign assembly version to web site. However they can get assembly version info from console, windows, class library, web applications.

There is one way to get auto increment for assembly version for website.
Create blank solution, add web site project into it.

Add one class library to this solution from File -> Add -> New Project -> Class Library



Write a method which return assembly version of this class library as below

Open “AssemblyInfo.cs” file and paste following code

using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ClassLibrary1")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ClassLibrary1")]
[assembly: AssemblyCopyright("Copyright ©  2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components.  If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("e6761a90-b4a8-42cf-a455-c47a240dd8eb")]

// Version information for an assembly consists of the following four values:
//
//      Major Version
//      Minor Version
//      Build Number
//      Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("2.0.*")]

namespace ClassLibrary1
{
    public partial class AssemblyInfo
    {
        /// <summary>
        /// Get version numbers from Assembly
        /// </summary>
        /// <returns></returns>
        public static string GetAssemblyVersion()
        {
            var version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
            return string.Format("{0}.{1}.{2}.{3}", version.Major, version.Minor, version.Build, version.Revision);
        }
    }
}

Add reference of this class library in website project.

Write following code to get assembly version.

protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = "Version " + ClassLibrary1.AssemblyInfo.GetAssemblyVersion();
}



Now everytime you rebuild your solution, you will get different assembly version.

Thursday, June 27, 2013

Checklist for Outing / Trip / Picnic

1.    Decide place and date
2.    Inform all friends who are interested
3.    Collect money
4.    Take permissions of all the places from authorities
5.    Book Vehicle – bus
6.    Make arrangement for food
7.    Collect personal info of all members – Name, Contact number, Address, email id, emergency contact number
8.    Get vehicle details and driver info with contact number
9.    Get route map from source to destination
10. Always wear comfortable dress – Avoid jeans and tight clothes
11.  Sport Shoes – recommended
12. Avoid high heels sandal, loose chappals
13. Extra pair of dresses, chappals
14. Packed snacks - dry fruits, chiwda, farsan, biscuits, fruit cakes
15. Paper plates
16. Water bottle – **** Most important
17. Towel and napkin
18. Goggle, cap, scarf
19. Sweeter for winter or raincoat during rainy season
20. Umbrella
21. Camera
22. Torch
23. Sunscreen cream – If going to play in water
24. Mobile – Charge it a day before
25. Cash Money
26. Medicines
27. Identity proof
28. Garbage bags – Don’t though wastes at road or destination
29. Poly bags – Useful to keep wet clothes in rainy season
30. Small polythin – Can keep mobile, money, identity proof in rainy season
31. Remember or keep any telephone number on paper in case of mobile lost
32. Same dress code - It’s very easy to identify each other
33. Paper Soap *** or liquid soap – In most of the food place you will never get any soap


I added all the possible items. Please suggest if I am missing anything.
If you feel it’s useful for you, please mark below or leave comments.

How to assign function output to table variable

I have Split function and want to store its output to table varaibale.

DECLARE @ParsedTable AS TABLE (Item VARCHAR(MAX)) ;
INSERT @ParsedTable SELECT * FROM dbo.Udf_split('505,468',',');
SELECT * FROM Employee WHERE  userid IN (SELECT * FROM   @ParsedTable)
 
     
-- =============================================    
-- Description:  Used for Spliting the list    
-- =============================================    
CREATE FUNCTION [dbo].[Udf_split] (@List  VARCHAR(max), @Delim CHAR)    
returns @ParsedTable TABLE (Item VARCHAR(max))    
AS    
  BEGIN    
      DECLARE @list1 VARCHAR(max),@Pos INT, @rList VARCHAR(max)    
   
      SET @list = Ltrim(Rtrim(@list)) + @Delim    
      SET @pos = Charindex(@delim, @list, 1)    
   
      WHILE @pos > 0     
        BEGIN    
            SET @list1 = Ltrim(Rtrim(LEFT(@list, @pos - 1)))    
   
            IF @list1 <> ''    
              INSERT INTO @ParsedTable VALUES (Cast(@list1 AS VARCHAR(max)))    
   
            SET @list = Substring(@list, @pos + 1, Len(@list))    
            SET @pos = Charindex(@delim, @list, 1)    
        END    
   
      SELECT @rlist = COALESCE(@rlist+',', '') + item FROM (SELECT DISTINCT Item FROM @ParsedTable) t    
   
      RETURN    

  END

How to get random records in Sybase IQ and SQL Server

Use Rand(PrimaryKey) function to get random number along with milliseconds as below


SELECT TOP 5 * FROM Employee Order by RAND( CONVERT(BIGINT,RAND(ID)*1000000000) - DATEPART( Millisecond   ,GETDATE()))

Dunkirk Line Post Office, Pune 411014

Yesterday I got message from Post Office that I received one speed post letter, collect it from Dunkirk Line Post Office, Pune - 411014 within 2 days.

First problem was message was in worst handwriting that nobody understands what the actual address he mentioned is.

Second, anybody doesn’t know about where is Dunkirk Line Post Office.


Thanks to GOOGLE. Finally I was able to view in Google maps.



View Larger Map

It is inside Air Force area.

I never visited before there. I always thought it’s a restricted area.

When you visit from Vimannagar to Chandannagar, at Chandannagar 2nd square [Near to toll tax kind of stuff], take left.

This is the second gate of entrance in Air Force Zone. Go inside.

Security guards will ask you about purpose, ID card.

Make entry in their register.

If you have bike, keep helmet with you otherwise you have walk almost 1 km.
Four vehicles are not allowed inside military premises.

After making entry, go straight [till road end], take left. At last you come in front of Canteen. Park you bike in parking area.

Dunkirk Line Post Office is behind military canteen. Beside SBI ATM [Don’t confuse with ATM. Actually there are two SBI ATM. First ATM inside first entrance gate. Don't go there. Visit to second ATM.]

Always visit post office between 9-11 AM.

I don't understand why government offices are not making people life easier. Whats the use of post office inside military zone for common man?

Monday, June 24, 2013

How to avoid postback on ENTER key press in textbox or How to block ENTER key press in textbox

$(document).ready(function() {

    // Block ENTER key in textbox
    $('#txtSearch').keypress(function(event) {
        if ((event.keyCode || event.which) == 13) {
            event.preventDefault();
            return false;
        }
    });

})

Thursday, June 20, 2013

Find checkbox in row of each grid using JQuery

if ($(grd.rows[i]).find("input[id*='chkDatabase']:checkbox").attr('checked') == true) {
grd.rows[i].style.display = '';
}
else
{
grd.rows[i].style.display = 'none';

}