Posts

Showing posts from February, 2010

How to pass server values to Javascript using Eval()

In my application I have a target to show message if user does not have permission to navigate to another page. I can do this by using server code but it will make a round trip to server and make a bad user experience so, I decided to use java script. Following is the function of Java Script <script language="javascript" type="text/javascript"> function func_Message(obj) { if (parseFloat(obj)>0) { return true; } else { alert("Please assign a value before viewing the details"); return false; } } </script> And following is the code of Link Button from where I am passing value to Java Script Function <asp:LinkButton ID="lnk_Details" runat="server" Text="Details" CommandArgument='<%# Eval("festi_id") +"~" + Eval("user_id") %>' CommandName="ViewDet...

Disbale JIT in .net / Application level Exception handling in .net

Image
Download Code Example I was developing windows application for a well known company of World. This application was in C#.net 2005. As per requirement I have to show user defined message whenever an Exception occurs in the application. The answer is very simply write a simple Try{},Catch{} statement to handle exception. Suppose I have a code of 1000 line unwanted code and error handling creates extra thread while executing the application. I had search on the internet and found a solution to disable the JIT debugger. It works but still it is showing the application information related to functions etc. used in the code. Now, a major issue had risen from client, i.e. he don’t want to show JIT information to user he wants to show his own message whenever any Exception occurs. Offf…. Now that’s the task to which needs to done. I cannot use Try{},Catch{} as this decrease the application performance. Finally I came to the solution. I had wired an event with application to handle applicatio...

How to alter Auto Increment field in Sql server

It is not possible to remove Auto Increment field using Alter command in Sql Server. What we can use is SET IDENTITY_INSERT Take this following example this creates a table with auto increment field and still insert data to the same. Generally if you try to insert the data into auto increment field it will through error. But if we use SET IDENTITY_INSERT <Table Name>ON it will allow you to insert data into auto increment field. Note: Make sure after completing this operation you set the value to SET IDENTITY_INSERT <Table Name>OFF --Create table and its columns CREATE TABLE [test].[Table_1] ( [Id][int] NOT NULL IDENTITY (1, 1), [Name][nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL); GO ALTER TABLE [test].[Table_1] ADD CONSTRAINT [PK_Table_1] PRIMARY KEY CLUSTERED ([Id]) GO SET IDENTITY_INSERT [test].[Table_1] ON GO INSERT INTO [test].[Table_1] ([Id], [Name]) VALUES (1, 'Narender') GO INSERT INTO [test].[Table_1] ([Id], [Name]) VALUES (3, ...