Friday 24 February 2012

How to Increse the Upload size of a file in ASP.Net 2.0

Some it is there to Upload a File of higher size to the server, 
but .net 2.0 upload control doesn't allows it make it to take
higher file size just go your web config and find the <configuration>
then <System.web> and inside it write the code below. You need to change
the Execution time and maxRequestLength as per your need.
here the default file size it can take is of 4mb and the time out is of 90 
seconds.
Even if some one uploads file of more size it will throw the error.
So in your try catch block check <Fileupload Control ID >.PostedFile.ContentLenth not be
more than the maxRequestLength given in the <httpRuntime> of the web.config file of 
your project.
 <httpRuntime
executionTimeout = "110" [in Seconds][number ]
maxRequestLength = "4096" [number] 
requestLengthDiskThreshold = "80" [number]
useFullyQualifiedRedirectUrl = "false" [true|false]
minFreeThreads = "8" [number]
minLocalRequestFreeThreads = "4" [number]
appRequestQueueLimit = "5000" [number]
enableKernelOutputCache = "true" [true|false]
enableVersionHeader = "true" [true|false]
apartmentThreading = "false" [true|false]
requireRootedSaveAsPath = "true" [true|false]
enable = "true" [true|false]
sendCacheControlHeader = "true" [true|false]
shutdownTimeout = "90" [in Seconds][number]
delayNotificationTimeout = "5" [in Seconds][number]
waitChangeNotification = "0" [number]
maxWaitChangeNotification = "0" [number]
enableHeaderChecking = "true" [true|false]
/> 
Refer the links:
1) http://www.dotnetspark.com/kb/1269-file-upload-control-asp-net-with-codings.aspx 
2)http://msdn.microsoft.com/en-us/library/e1f13641%28v=vs.71%29.aspx

Thursday 23 February 2012

Opacity for IE-7 and IE-8

filter:Alpha(Opacity=40);/* IE7 and under */
-ms-filter: "Alpha(Opacity=40)"; /* IE8 */

How to use Gradient Effect for IE-7 and IE-8

use these two lines in the ID or class where you required the Effect. 
 
filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#ededed')/* ie7 */
-ms-filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#ededed')/* ie8 */

How to set the display:inline-block in IE-7

 
Here is the Trick to do it 
zoom1/* ie7 hack for display:inline-block */

How to Check Wheather a Video URL is valid or not


Hi guys, some times you may got a requirement that whether the video url provided by the user is valid or not, you can check it by using the below codes.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
public class UrlValidity
{
  public static bool IsValid(string Url)
  {
   Stream sStream = default(Stream);
   HttpWebRequest URLReq = default(HttpWebRequest);
   HttpWebResponse URLRes = default(HttpWebResponse);

  try {
        URLReq = WebRequest.Create(Url);
        URLRes = URLReq.GetResponse();
        sStream = URLRes.GetResponseStream();
        string reader = new StreamReader(sStream).ReadToEnd();
        return true;
     }
     catch (Exception ex) 
      {
           //Url not valid
           return false;
      }
  }
}