Posts

Showing posts from 2008

How to show icon in browser header / Fevicon

To complete this task you have to visit http://www.html-kit.com/favicon/ Provide your image which you want to use a icon it will generate icon for you. Follow the steps given in site. Write following code in header section of page. <link rel="shortcut icon" href="Images/favicon.ico" type="image/ico"> <link rel="shortcut icon" type="image/ico" href="Images/favicon.ico">

Convert Video to .Flv Using c#.net on Web.

The actual post has shifted. Please click here to visit actual post.

How to implement Google Analytics in web site

To implement Google analytics you must have an Gmail account.

Tips For Database Optimization/Operations with C#

Recommended reading C# optimization tips 1) Return Multiple Resultsets The database code if has request paths that go to the database more than once then, these round-trips decreases the number of requests per second your application can serve. Solution: Return multiple resultsets in a single database request, so that you can cut the total time spent communicating with the database. You'll be making your system more scalable, too, as you'll cut down on the work the database server is doing managing requests. 2) Connection Pooling and Object Pooling Connection pooling is a useful way to reuse connections for multiple requests, rather than paying the overhead of opening and closing a connection for each request. It's done implicitly, but you get one pool per unique connection string. Make sure you call Close or Dispose on a connection as soon as possible. When pooling is enabled, calling Close or Dispose returns the connection to the pool instead of closing the underlying dat...

Best Practices to Improve ASP.Net Web Application Performance. Part - 4

Recommended read part - 3 14) Avoid Unnecessary Indirection How it affects performance: When you use byRef, you pass pointers instead of the actual object. Many times this makes sense (side-effecting functions, for example), but you don't always need it. Passing pointers results in more indirection, which is slower than accessing a value that is on the stack. Solution: When you don't need to go through the heap, it is best to avoid it there by avoiding indirection. 15) Use "ArrayLists" in place of arrays How it improves performance An ArrayList as everything that is good about an array PLUS automatic sizing, Add, Insert, Remove, Sort, Binary Search. All these great helper methods are added when implementing the IList interface. Tradeoffs: The downside of an ArrayList is the need to cast objects upon retrieval. 16) Always check Page.IsValid when using Validator Controls Always make sure you check Page.IsValid before processing your forms when using Validator Controls. ...

Best Practices to Improve ASP.Net Web Application Performance. Part - 3

Recommended Read Part - 2 6) Use the String builder to concatenate string How it affects performance: String is Evil when you want to append and concatenate text to your string. All the activities you do to the string are stored in the memory as separate references and it must be avoided as much as possible. i.e. When a string is modified, the run time will create a new string and return it, leaving the original to be garbage collected. Most of the time this is a fast and simple way to do it, but when a string is being modified repeatedly it begins to be a burden on performance: all of those allocations eventually get expensive. Solution: Use String Builder when ever string concatenation is needed so that it only stores the value in the original string and no additional reference is created. 7) Avoid throwing exceptions How it affects performance: Exceptions are probably one of the heaviest resource hogs and causes of slowdowns you will ever see in web applications, as well as windows ...

A name was started with an invalid character. Error processing resource

This error fires when you run your application on local host. Generally the reason behind this error is configuration of IIS. The general cause of this error is installation of .net 2005 before installing IIS To know how to configure IIS click here. Here is the solution of this error Go to run type cmd Browse for windows directory: For ex. C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\ aspnet_regiis.exe –i Or C:\WINNT\Microsoft.NET\Framework\v2.0.50727\ aspnet_regiis.exe –i Hope this will work

How to configure site on IIS (Internet information server)

Image
When I was new to web development I do not have any idea about IIS. That is a major task to configure web site to IIS. IIS have too many properties which is to be set to run and asp.net application. Here are few things which we have to keep while setup of machines for .net 2005 Steps to configure IIS:- After windows installation we have to install IIS. Install Sql server 2005 Install .net 2005 If you install .net 2005 before installing IIS it will raise an error after configuring asp.net site The error will be “A name was started with an invalid character. Error processing resource” For solution click here Following are the steps to configure IIS Go to Start >> Run >>type inetmgr Screen of IIS will appear Follow following steps:- Display IIS window Open tree and come to default websites Right click on default web sites Open new>> Virtual directory Click on next button Provide ...

How to show images with Animation

You will find so many scripts to do the same task but, only one issue will arise with all the scripts “does these are browser compatible”. May the answer is yes or may be no. But, here is the solution you have to use “SpryEffects.js”. This is truly browser compatible is easy to implement. I have a small example that is using this “JS” to animate images. Download “SpryEffects.js” from net. <script language="javascript" type="text/javascript"> function MM_effectGrowShrink(targetElement, duration, from, to, toggle, referHeight, growFromCenter) { Spry.Effect.DoGrow(targetElement, {duration: duration, from: from, to: to, toggle: toggle, referHeight: referHeight, growCenter: growFromCenter}); } function showimage(str_path) { var obj=document.getElementById("a1"); str_path=str_path.replace('images/','images/large/'); var int_left=screen.width; if (int_left>1024) { int_left=int_left-1024; ...

Best Practices to Improve ASP.Net Web Application Performance. Part - 2

Recommended Read Part - 1 3) Disable View State of a Page if possible View state is a fancy name for ASP.NET storing some state data in a hidden input field inside the generated page. When the page is posted back to the server, the server can parse, validate, and apply this view state data back to the page's tree of controls. View state is a very powerful capability since it allows state to be persisted with the client and it requires no cookies or server memory to save this state. Many ASP.NET server controls use view state to persist settings made during interactions with elements on the page, for example, saving the current page that is being displayed when paging through data. How it affects performance: There are a number of drawbacks to the use of view state, however. It increases the total payload of the page both when served and when requested. There is also an additional overhead incurred when serializing or deserializing view state data that is posted back to the server. ...

Best Practices to Improve ASP.Net Web Application Performance. Part -1

Performance tuning can be tricky. It's especially tough in Internet-related projects with lots of components running around, like HTML client, HTTP network, Web server, middle-tier components, database components, resourcemanagement components, TCP/IP networks, and database servers. Performance tuning depends on a lot of parameters and sometimes, by changing a single parameter, performance can increase drastically. Introduction This document lists out some tips for optimizing ASP.Net Web applications and many traps and pitfalls are discussed as follows : Tips For Web Application 1) Turn off Tracing unless until required Tracing is one of the wonderful features which enable us to track the application's trace and the sequences. However, again it is useful only for developers and you can set this to "false" unless you require to monitor the trace logging. How it affects performance: Enabling tracing adds performance overhead and might expose private information, so it s...

URL rewriting and SEO

Image
Download c# code What is URL REWRITING? URL rewriting is the process of intercepting an incoming Web request and redirecting the request to a different resource. When performing URL rewriting, typically the URL being requested is checked and, based on its value, the request is redirected to a different URL. For example, in the case where a website restructuring caused all of the Web pages in the /people/ directory to be moved to a /info/employees/ directory, you would want to use URL rewriting to check if a Web request was intended for a file in the /people/ directory. If the request was for a file in the /people/ directory, you'd want to automatically redirect the request to the same file, but in the /info/employees/ directory instead. Common Uses of URL Rewriting Creating data-driven ASP.NET websites often results in a single Web page that displays a subset of the database's data based on querystring parameters. For example, in designing an e-commerce site, one of your tasks ...

Validation of viewstate MAC failed.

Image
Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster. I am facing this error from last two days, I tried so many resolutions to resolve this problem. I had tried to know the reason of this error but, unfortunately I am not able to reach the cause of this error. But, I had find a solution of this error. Update your web.config with following attributes. <pages validateRequest="false" enableEventValidation="false" viewStateEncryptionMode ="Never" enableViewStateMac="false"> Download Sample Web.config

Use Google maps in Asp.net C#

Image
Download this with example with code This is very simple to use Google maps to your application To use Google map you must have an Google account go to HTTP://code.google.com/apis/maps/signup.html login and create key for your website. Please use the example attached with this post. After generating key replace this key in web.config. For any queries please let me know.

Exporting datagrid to Excel using C#.net

Datagrid is one of the most coolest controls in the Asp.net. One thing that all developers need is to put the data grid data into excel sheet. In this article I will show you that how you can export your datagrid data to Excel file. Exporting datagrid to excel might sounds complex but its pretty simple. Let's see how this can be done. Here is the code: protected void img_Export_Click(object sender, EventArgs e) { // export to excel DataTable dt = new DataTable(); dt.Columns.Add("a"); dt.Columns.Add("b"); dt.Columns.Add("c"); dt.Rows.Add(); dt.Rows[0]["a"] = "aaaaaaaaaaaaaa"; dt.Rows[0]["b"] = "bbbbbbb"; dt.Rows[0]["c"] = "ccccccccccc"; dt.Rows.Add(); dt.Rows[1]["a"] = "11111111111111111"; dt.Rows[1]["b"] = "222222222222"; dt.Rows[1]["...

Code of logout in c#.net

Try this code may this will help. Paste this code on masterpage’s load event. If you are not using master pages then you have to paste this code of all the pages (on load event). Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1)); Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Cache.SetNoStore(); On logout You have to write Session.Abandon(); Session.Clear(); And redirect to login page.

How to add unlimited zero's after decimal in c#.net

here is the code: int yournumber = 12; Console.WriteLine(yournumber.ToString("0.00##################")); Console.WriteLine(yournumber.ToString("0.000#################")); Console.WriteLine(yournumber.ToString("0.0000################"));

Convert Video to .Flv Using c#.net on Web.

Having trouble playing .flv in IIS click here for solution Having trouble Setting up IIS click here for solution The method to convert video to .flv is too easy. You can download following files from .net 1)ffmpeg.exe 2) ffplay.exe 3) pthreadGC2.dll After downloading all the files Follow the steps written:- 1)Make a new .net web site or windows application. 2)Copy and paste all the 3 above written files to root location 3)Copy and Paste code written below 4)Put an upload to page and rename to “ fileuploadImageVideo” 5)put and button and rename to btn_Submit 6)Make 3 folders OriginalVideo, ConvertVideo, Thumbs 7)Import Class “using System.IO;” private bool ReturnVideo(string fileName) { string html = string.Empty; //rename if file already exists int j = 0; string AppPath; string inputPath; string outputPath; string imgpath; AppPath = Request.PhysicalApplicationPath; //Get the application path inputPath = AppPath + "OriginalVideo"; ...

Cluster and Non Cluster indexes

When I first started using SQL Server as a novice, I was initially confused as to the differences between clustered and non-clustered indexes. As a developer, and new DBA, I took it upon myself to learn everything I could about these index types, and when they should be used. This article is a result of my learning and experience, and explains the differences between clustered and non-clustered index data structures for the DBA or developer new to SQL Server. If you are new to SQL Server, I hope you find this article useful. As you read this article, if you choose, you can cut and paste the code I have provided in order to more fully understand and appreciate the differences between clustered and non-clustered indexes. Part I: Non-Clustered Index Creating a Table To better explain SQL Server non-clustered indexes; let’s start by creating a new table and populating it with some sample data using the following scripts. I assume you have a database you can use for this. If not, you will w...

Play Video with asp.net and c#

.flv is the preferred format to play videos online. You can download .flv player from http://www.any-flv-player.com and then go to Publish>>Publish for web. This will generate code copy and paste code to .aspx page. It will start playing your .flv file You can face a major problem on server or IIS it will not play video. Go to settings and set MIME type to .flv

How to make user in Sql server database.

Image
To make a user in sql server you have the rights. to create user go to Security=>> Logins>> Right click on Logins Login Name : jayant Select option:Sql server authentication Un check : Enforece password policy. Refer Image Below Now close sql management studio and re login with jayant Try to access other databases, it will show error, means you have sucessfuly make a new use for new datbase.

Crosstab report in SQL server (Pivot)

Microsoft introduces new operators PIVOT and UNPIVOT in SQL Server 2005. Traditionally we create queries using the CASE statement and aggregate function in order to produce cross-tab reports. This article illustrates the usage of the new operators, PIVOT and UNPIVOT. Let us assume that we have a table as described below. Create table #MyTable (yearofJoining int, EmpId int, Deptid int) go insert into #MyTable select 1990,1,1 insert into #MyTable select 1991,2,2 insert into #MyTable select 1990,3,4 insert into #MyTable select 1991,4,2 insert into #MyTable select 1990,5,1 insert into #MyTable select 1990,6,3 insert into #MyTable select 1992,7,3 insert into #MyTable select 1990,8,4 insert into #MyTable select 1993,9,1 insert into #MyTable select 1994,10,2 insert into #MyTable select 1990,11,3 insert into #MyTable select 1995,12,3 insert into #MyTable select 1995,14,3 insert into #MyTable select 1995,15,3 insert into #MyTable select 1995,16,6 go In order to create a cross tab report, we ...

Event after Load

Yes there is an event LoadComplete() for ex. protected void Page_LoadComplete(object sender, EventArgs e) This event is for tasks that require that all other controls on the page be loaded. Suppose I have to show messages on page and then I have to redirect to some other page. I Have a small example; I have a page which connect me to some more URL’s but to some reasons I have shift that page to another location. Now I have to show message on page “this page has shifted to another location. This page will automatically redirect to another page” So, this can be done only after page load so, this is the best event to place that code