.Net & SharePoint '07

Technical blog for .Net and all SharePoint 2007 related Information

About the author

Me(Prince) and my wife are B.E in I.T & C.S.E respectively.  I a certified MCPD: Web from 2007 Dec. I am Intrestes in Web Application, MOSS, EPM, etc.
Now working with Deira International School, as IT Application & Help Manager. I have started my career as "Software Developer" @  REACH Sewn Technologies and Consulting Pvt. Ltd, Bangalore India from Oct 2004 to Feb 2006, then as "Web & Intranet Developer" @ Fosroc International Ltd, Dubai from April 2006 to Sep 2009.
You can catch me on mail@jpy-tech.com or mail@princepy.com. Or on 00971 - 50 - 4284530 

Google Translate

Tag cloud

Calendar

<<  February 2012  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
2728291234
567891011

View posts in large calendar

RecentComments

Comment RSS

Google Your Location


Downloading Files C#

thanks to http://dotnetslackers.com/community/blogs/haissam/archive/2007/04/03/Downloading-Files-C_2300_.aspx

A lot of questions are being asked about downloading a file from the web server to the client in ASP.NET. I have updated this blog post due to the high number of view & comments. You will realize i added a function called "ReturnExtension" which will return the proper content type and set it to the Response.ContentType property. Almost well known file types are supported.

C# Code

// Get the physical Path of the file(test.doc)
   string filepath = Server.MapPath("test.doc");

   // Create New instance of FileInfo class to get the properties of the file being downloaded
   FileInfo file = new FileInfo(filepath);
 
   // Checking if file exists
   if (file.Exists)
   {
    // Clear the content of the response
    Response.ClearContent();
   
    // LINE1: Add the file name and attachment, which will force the open/cance/save dialog to show, to the header
    Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
   
    // Add the file size into the response header
    Response.AddHeader("Content-Length", file.Length.ToString());

    // Set the ContentType
    Response.ContentType = ReturnExtension(file.Extension.ToLower());

    // Write the file into the response (TransmitFile is for ASP.NET 2.0. In ASP.NET 1.1 you have to use WriteFile instead)
    Response.TransmitFile(file.FullName);

    // End the response
    Response.End();
   }

private string ReturnExtension(string fileExtension)
{
     switch (fileExtension)
            {
                case ".htm":
                case ".html":
                case ".log":
                    return "text/HTML";
                case ".txt":
                    return "text/plain";
                case ".doc":
                    return "application/ms-word";
                case ".tiff":
                case ".tif":
                    return "image/tiff";
                case ".asf":
                    return "video/x-ms-asf";
                case ".avi":
                    return "video/avi";
                case ".zip":
                    return "application/zip";
                case ".xls":
                case ".csv":
                    return "application/vnd.ms-excel";
                case ".gif":
                    return "image/gif";
                case ".jpg":
                case "jpeg":
                    return "image/jpeg";
                case ".bmp":
                    return "image/bmp";
                case ".wav":
                    return "audio/wav";
                case ".mp3":
                    return "audio/mpeg3";
                case ".mpg":
                case "mpeg":
                    return "video/mpeg";
                case ".rtf":
                    return "application/rtf";
                case ".asp":
                    return "text/asp";
                case ".pdf":
                    return "application/pdf";
                case ".fdf":
                    return "application/vnd.fdf";
                case ".ppt":
                    return "application/mspowerpoint";
                case ".dwg":
                    return "image/vnd.dwg";
                case ".msg":
                    return "application/msoutlook";
                case ".xml":
                case ".sdxl":
                    return "application/xml";
                case ".xdp":
                    return "application/vnd.adobe.xdp+xml";
                default:
                    return "application/octet-stream";
}

N.B:  If you want to bypass the Open/Save/Cancel dialog you just need to replace LINE1 by the below code

Response.AddHeader("Content-Disposition", "inline; filename=" + file.Name);

Response.TransmitFile VS Response.WriteFile:
 1- TransmitFile: This method sends the file to the client without loading it to the Application memory on the server. It is the ideal way to use it if the file size being download is large.
 2- WriteFile: This method loads the file being download to the server's memory before sending it to the client. If the file size is large, you might the ASPNET worker process might get restarted.

Hope this helps,


Posted by Admin on Saturday, January 22, 2011 3:21 AM
Permalink | Comments (0) | Post RSSRSS comment feed

Check Uncheck all CheckBoxes in an ASP.NET GridView using jQuery

Check Uncheck all CheckBoxes in an ASP.NET GridView using jQuery

<script type="text/javascript">
    $(document).ready(function() {
        var chkBox = $("input[id$='ChkAll']");
        chkBox.click(
             function() {
                 $("#GridView1 INPUT[type='checkbox']")
                 .attr('checked', chkBox
                 .is(':checked'));
             });

        // To deselect CheckAll when a GridView CheckBox
        // is unchecked
        $("#GridView1 INPUT[type='checkbox']").click(
        function(e) {
            if (!$(this)[0].checked) {
                chkBox.attr("checked", false);
            }
        });
    });
</script>


Posted by Admin on Monday, January 10, 2011 10:09 AM
Permalink | Comments (0) | Post RSSRSS comment feed

C# 4.0's New Features - Dynamic (Good Links)


Tags: ,
Categories: ASP.NET 4 | c# 4
Posted by Admin on Saturday, January 08, 2011 7:30 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Implementing Dynamic Interfaces

thanks to By Bill Wagner

One great advantage of dynamic programming is the ability to build types whose public interfaces change at runtime based on how you use these types. C# provides that ability through dynamic, the System.Dynamic.DynamicObject class, and the System.Dynamic.IDynamicMetaObjectProvider interface. Using these tools, you can create your own types that have dynamic capabilities.

The simplest way to create a type with dynamic capabilities is to derive from System.Dynamic.DynamicObject. That type implements the IDynamicMetaObjectProvider interface using a private nested class. This private nested class does the hard work of parsing expressions and forwarding those to one of a number of virtual methods in the DynamicObject class. That makes it a relatively simple exercise to create a dynamic class, if you can derive from DynamicObject. There are a number of examples on MSDN that discuss how to use this class. A great place to start is this article: Walkthrough: Creating and Using Dynamic Objects.

Using DynamicObject makes it much easier to implement a type that behaves dynamically. DynamicObject hides much of the complexity of creating dynamic types. It has quite a bit of implementation to handle dynamic dispatch for you. But sometimes you want to create a dynamic type and you can’t use DynamicObject because you need a different base class. Or, you may want to have additional control over the mechanism involved implementing the dynamic behavior. 

For that reason, I’m going to show you how to create the dynamic dictionary by implementing IDynamicMetaObjectProvider yourself, instead of relying on DynamicObject to do the heavy lifting for you. Using IDynamicMetaObjectProvider ties into the DLR infrastructure at a lower level. The DLR extensively uses expression trees to implement dynamic behavior. Fully covering the expression trees is beyond the scope of this article, but you can read the MSDN article on expression trees and documentation on the DLR Web site.

Implementing IDynamicMetaObjectProvider means implementing one method: GetMetaObject. Here’s a version of DynamicDictionary that implements IDynamicMetaObjectProvider, instead of deriving from DynamicObject:

using System;
using System.Collections.Generic;
using System.Text;
using System.Dynamic;
using System.IO;
using System.Linq.Expressions;
class DynamicDictionary : IDynamicMetaObjectProvider
 {
     #region IDynamicMetaObjectProvider Members
     DynamicMetaObject IDynamicMetaObjectProvider.GetMetaObject(System.Linq.Expressions.Expression parameter)
     {
         return new DynamicDictionaryMetaObject(parameter, this);
     }
     #endregion
 
     private class DynamicDictionaryMetaObject : DynamicMetaObject
     {
         internal DynamicDictionaryMetaObject(System.Linq.Expressions.Expression parameter,DynamicDictionary value) : base(parameter, BindingRestrictions.Empty, value)
         {
         }
 
         public override DynamicMetaObject BindSetMember(SetMemberBinder binder,
             DynamicMetaObject value)
         {
             // Method to call in the containing class:
             string methodName = "SetDictionaryEntry";
 
             // setup the binding restrictions.
             BindingRestrictions restrictions =
                 BindingRestrictions.GetTypeRestriction(Expression, LimitType);
 
             // setup the parameters:
             Expression[] args = new Expression[2];
             // First parameter is the name of the property to Set
             args[0] = Expression.Constant(binder.Name);
             // Second parameter is the value
             args[1] = Expression.Convert(value.Expression, typeof(object));
 
             // Setup the 'this' reference
             Expression self = Expression.Convert(Expression, LimitType);
 
             // Setup the method call expression
             Expression methodCall = Expression.Call(self,
                     typeof(DynamicDictionary).GetMethod(methodName),
                     args);
 
             // Create a meta object to invoke Set later:
             DynamicMetaObject setDictionaryEntry = new DynamicMetaObject(
                 methodCall,
                 restrictions);
             // return that dynamic object
             return setDictionaryEntry;
         }
 
         public override DynamicMetaObject BindGetMember(GetMemberBinder binder)
         {
             // Method call in the containing class:
             string methodName = "GetDictionaryEntry";
 
             // One parameter
             Expression[] parameters = new Expression[]
             {
                 Expression.Constant(binder.Name)
             };
 
             DynamicMetaObject getDictionaryEntry = new DynamicMetaObject(
                 Expression.Call(
                     Expression.Convert(Expression, LimitType),
                     typeof(DynamicDictionary).GetMethod(methodName),
                     parameters),
                 BindingRestrictions.GetTypeRestriction(Expression, LimitType));
             return getDictionaryEntry;
         }
 
         public override DynamicMetaObject BindInvokeMember(
             InvokeMemberBinder binder, DynamicMetaObject[] args)
         {
             StringBuilder paramInfo = new StringBuilder();
             paramInfo.AppendFormat("Calling {0}(", binder.Name);
             foreach (var item in args)
                 paramInfo.AppendFormat("{0}, ", item.Value);
             paramInfo.Append(")");
 
             Expression[] parameters = new Expression[]
             {
                 Expression.Constant(paramInfo.ToString())
             };
             DynamicMetaObject methodInfo = new DynamicMetaObject(
                 Expression.Call(
                 Expression.Convert(Expression, LimitType),
                 typeof(DynamicDictionary).GetMethod("WriteMethodInfo"),
                 parameters),
                 BindingRestrictions.GetTypeRestriction(Expression, LimitType));
             return methodInfo;
         }
     }
 
     private Dictionary<string, object> storage = new
         Dictionary<string, object>();
 
     public object SetDictionaryEntry(string key, object value)
     {
         if (storage.ContainsKey(key))
             storage[key] = value;
         else
             storage.Add(key, value);
         return value;
     }
 
     public object GetDictionaryEntry(string key)
     {
         object result = null;
         if (storage.ContainsKey(key))
         {
             result = storage[key];
         }
         return result;
     }
 
     public object WriteMethodInfo(string methodInfo)
     {
         Console.WriteLine(methodInfo);
         return 42; // because it is the answer to everything
     }
 
     public override string ToString()
     {
         StringWriter message = new StringWriter();
         foreach (var item in storage)
             message.WriteLine("{0}:\t{1}", item.Key, item.Value);
         return message.ToString();
     }
 }

GetMetaObject() returns a new DynamicDictionaryMetaObject whenever it is called. Here’s where the first complexity enters the picture. GetMetaObject() is called every time any member of the DynamicDictionary is invoked. Call the same member 10 times, GetMetaObject() gets called 10 times. Even if your methods are statically defined in DynamicDictionary, GetMetaObject() will be called, and will intercept those methods to invoke possible dynamic behavior. Remember that dynamic objects are statically typed as dynamic, therefore have no compile time behavior defined. Every member access is dynamically dispatched.

The DynamicMetaObject is responsible for building an Expression Tree that executes whatever code is necessary to handle the dynamic invocation. Its constructor takes the expression and the dynamic object as parameters. After the dynamic meta object is constructed, one of its Bind methods is called. The method’s responsibility is to construct another DynamicMetaObject that contains the expression to execute the dynamic invocation. The first DynamicMetaObject is responsible for creating expression trees whenever an operation must be bound to a target. (That operation could be anything: an operator, property accessor, or method call). The second DynamicMetaObject is responsible for executing an expression tree for a single operation on a single object. That may seem a bit cumbersome, but it helps the DLR’s caching mechanism with providing more efficient dispatch. Let’s walk through the two Bind methods necessary to implement the DynamicDictionary: BindSetMember and BindGetMember.

BindSetMember constructs an expression tree that will call DynamicDictionary.SetDictionaryEntry() to set a value in the dictionary. Here’s its implementation:

public override DynamicMetaObject BindSetMember(SetMemberBinder binder, DynamicMetaObject value)
 {
     // Method to call in the containing class:
     string methodName = "SetDictionaryEntry";
 
     // setup the binding restrictions.
     BindingRestrictions restrictions =
         BindingRestrictions.GetTypeRestriction(Expression, LimitType);
 
     // setup the parameters:
     Expression[] args = new Expression[2];
     // First parameter is the name of the property to Set
     args[0] = Expression.Constant(binder.Name);
     // Second parameter is the value
     args[1] = Expression.Convert(value.Expression, typeof(object));
    
     // Setup the 'this' reference
     Expression self = Expression.Convert(Expression, LimitType);
 
     // Setup the method call expression
     Expression methodCall = Expression.Call(self,
             typeof(DynamicDictionary).GetMethod(methodName),
             args);
 
     // Create a meta object to invoke Set later:
     DynamicMetaObject setDictionaryEntry = new DynamicMetaObject(
         methodCall,
         restrictions);
     // return that dynamic object
     return setDictionaryEntry;
 }

Metaprogramming quickly gets confusing, so let’s walk through this slowly. The first line sets the name of the method called in the DynamicDictionary, “SetDictionaryEntry”. Notice that SetDictionary returns the right hand side of the property assignment. That’s important because this construct must work:

DateTime current = propertyBag2.Date = DateTime.Now;

Without setting the return value correctly, that construct won’t work.

 Next, this method initializes a set of BindingRestrictions. Most of the time, you’ll use restrictions like this one, restrictions given in the source expression, and for the type used as the target of the dynamic invocation.

The rest of the method constructs the method call expression that will invoke SetDictionaryEntry() with the property name, and the value used. The property name is a constant expression, but the value is a Conversion expression that will be evaluated lazily. Remember that the right hand side of the setter may be a method call or expression with side effects. Those must be evaluated at the proper time. Otherwise, setting properties using the return value of methods won’t work:

propertyBag2.MagicNumber = GetMagicNumber();

Of course, to implement the dictionary, you have to implement BindGetMember as well. BindGetMember works almost exactly the same way. It constructs an expression to retrieve the value of a property from the dictionary.

public override DynamicMetaObject BindGetMember(GetMemberBinder binder)
{
     // Method call in the containing class:
     string methodName = "GetDictionaryEntry";
 
     // One parameter
     Expression[] parameters = new Expression[]
     {
         Expression.Constant(binder.Name)
     };
 
     DynamicMetaObject getDictionaryEntry = new DynamicMetaObject(
         Expression.Call(
             Expression.Convert(Expression, LimitType),
             typeof(DynamicDictionary).GetMethod(methodName),
             parameters),
         BindingRestrictions.GetTypeRestriction(Expression, LimitType));
     return getDictionaryEntry;
}

I add one more function so that you can see a bit more about how IDynamicMetaObjectProvider does its work. I create an implementation of BindInvokeMember() that prints the method name and all parameters to the console for any method that you call. This shows some of the extra work that you need to do to implement more dynamic behavior in an object. When your type involves dynamic methods, suddenly you need to determine more than just the property name to get or set. You need to look at each parameter to a method, including its type information. Remember that you also need to know the target of the method invocation. You already saw how to use the Expression property of the DynamicMetaObject to find the correct target.

To add runtime dispatch of methods, you override BindInvokeMember.The first parameter to BindInvokeMember gives you information about the method: its name, and return type. The second parameter contains the list of parameters. Notice that the parameter list is not a System.Object array. Instead, it’s an array of DynamicMetaObjects. You’re working with dynamic objects, so it makes sense that the parameters may themselves be dynamic, right? My override takes a rather simple way out, and just looks at the value of each DynamicMetaObject in the array of parameters, and creates a string that displays that information for you. Notice that you need to build up an expression tree containing the code you want executed in order to correctly override BindInvokeMember. The underlying framework will execute the expression to provide the value for you:

public override DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args)
 {
     StringBuilder paramInfo = new StringBuilder();
     paramInfo.AppendFormat("Calling {0}(", binder.Name);
     foreach (var item in args)
         paramInfo.AppendFormat("{0}, ", item.Value);
     paramInfo.Append(")");
 
     Expression[] parameters = new Expression[]
     {
         Expression.Constant(paramInfo.ToString())
     };
     DynamicMetaObject methodInfo = new DynamicMetaObject(
         Expression.Call(
         Expression.Convert(Expression, LimitType),
         typeof(DynamicDictionary).GetMethod("WriteMethodInfo"),
         parameters),
         BindingRestrictions.GetTypeRestriction(Expression, LimitType));
     return methodInfo;
 }

Before you go off and think this isn’t that hard, let me leave you with some thoughts from the experience writing this code. This is about as simple as a dynamic object can get. You have two APIs: property get, property set. The semantics are very easy to implement. Even with this very simple behavior, it was rather difficult to get right. Expression trees are hard to debug. They are hard to get right. More sophisticated dynamic types would have much more code. That would mean much more difficulty getting the expressions correct.

Furthermore, keep your mind on one of the opening remarks I made: every invocation on your dynamic object will create a new DynamicMetaObject, and invoke one of the Bind members. You’ll need to write these methods with an eye toward efficiency and performance. They will be called a lot, and they have much amount of work to do.

Implementing dynamic behavior can be a great way to approach some of your programming challenges. When you look at creating dynamic types, your first choice should be to derive from System.Dynamic.DynamicObject. On those occasions where you must use a different base class, you can implement IDynamicMetaObjectProvider yourself, but remember that this is a complicated problem to take on. Furthermore, any dynamic types involve some performance costs, and implementing them yourself may make those costs greater.

The ExpandoObject is the most common use case for creating a dynamic object. An Expando object can easily implement the properties that come across the network in JSON or XML format. You can implement more dynamic behavior for different JSON types. Leveraging dynamic capabilities means that you can create fewer concrete types, and yet have data driven types implement behavior based on the data they contain. For example, your JSON object may know how to transform itself into HTML display. You may create object that know how to control navigation in your web application. In general, you should consider creating your own dynamic implementations when you see that the behavior of a type is driven by the data it contains. Phil Haack wrote about this concept in his article: Fun With Method Missing and C# 4, where he implemented method_missing (from Ruby) in C# 4.0. As you look around you can find several examples of creating dynamic objects, as long as you look outside of the familiar C# background. Look at the dynamic programming models from the Ruby and Python communities. You’ll see many different techniques that you can now leverage in C# 4.0.


Categories: ASP.NET 4
Posted by Admin on Tuesday, January 04, 2011 8:47 PM
Permalink | Comments (0) | Post RSSRSS comment feed

My Prefered PDC 2008 topics

PDC 2008


Tags:
Posted by Admin on Tuesday, January 04, 2011 10:34 AM
Permalink | Comments (0) | Post RSSRSS comment feed

C# 4 - DynamicObject Class

The DynamicObject class enables you to override operations like getting or setting a member, calling a method, or performing any binary, unary, or type conversion operation. To illustrate the issue, let’s create a very simple object that overrides the “get property” operation, so that whenever you access a property it returns the property’s name as a string. This example has no practical value.

=> Microsoft

// The class derived from DynamicObject.
public class DynamicDictionary : DynamicObject
{
    // The inner dictionary.
    Dictionary<string, object> dictionary
        = new Dictionary<string, object>();

    // This property returns the number of elements
    // in the inner dictionary.
    public int Count
    {
        get
        {
            return dictionary.Count;
        }
    }

    // If you try to get a value of a property
    // not defined in the class, this method is called.
    public override bool TryGetMember(
        GetMemberBinder binder, out object result)
    {
        // Converting the property name to lowercase
        // so that property names become case-insensitive.
        string name = binder.Name.ToLower();

        // If the property name is found in a dictionary,
        // set the result parameter to the property value and return true.
        // Otherwise, return false.
        return dictionary.TryGetValue(name, out result);
    }

    // If you try to set a value of a property that is
    // not defined in the class, this method is called.
    public override bool TrySetMember(
        SetMemberBinder binder, object value)
    {
        // Converting the property name to lowercase
        // so that property names become case-insensitive.
        dictionary[binder.Name.ToLower()] = value;

        // You can always add a value to a dictionary,
        // so this method always returns true.
        return true;
    }
}

class Program
{
    static void Main(string[] args)
    {
        // Creating a dynamic dictionary.
        dynamic person = new DynamicDictionary();

        // Adding new dynamic properties.
        // The TrySetMember method is called.
        person.FirstName = "Ellen";
        person.LastName = "Adams";

        // Getting values of the dynamic properties.
        // The TryGetMember method is called.
        // Note that property names are case-insensitive.
        Console.WriteLine(person.firstname + " " + person.lastname);

        // Getting the value of the Count property.
        // The TryGetMember is not called,
        // because the property is defined in the class.
        Console.WriteLine(
            "Number of dynamic properties:" + person.Count);

        // The following statement throws an exception at run time.
        // There is no "address" property,
        // so the TryGetMember method returns false and this causes a
        // RuntimeBinderException.
        // Console.WriteLine(person.address);
    }
}

// This example has the following output:
// Ellen Adams
// Number of dynamic properties: 2

 => blogs.msdn.com

public class DynamicXMLNode : DynamicObject
{
    XElement node;
    public DynamicXMLNode(XElement node)
    {
        this.node = node;
    }
    public DynamicXMLNode()
    {
    }
    public DynamicXMLNode(String name)
    {
        node = new XElement(name);
    }
    public override bool TrySetMember(
        SetMemberBinder binder, object value)
    {
        XElement setNode = node.Element(binder.Name);
        if (setNode != null)
            setNode.SetValue(value);
        else
        {
            if (value.GetType() == typeof(DynamicXMLNode))
                node.Add(new XElement(binder.Name));
            else
                node.Add(new XElement(binder.Name, value));
        }
        return true;
    }
    public override bool TryGetMember(
        GetMemberBinder binder, out object result)
    {
        XElement getNode = node.Element(binder.Name);
        if (getNode != null)
        {
            result = new DynamicXMLNode(getNode);
            return true;
        }
        else
        {
            result = null;
            return false;
        }
    }
}

//And here is how you can use this class.

dynamic contact = new DynamicXMLNode("Contacts");
contact.Name = "Patrick Hines";
contact.Phone = "206-555-0144";
contact.Address = new DynamicXMLNode();
contact.Address.Street = "123 Main St";
contact.Address.City = "Mercer Island";
contact.Address.State = "WA";
contact.Address.Postal = "68402";


//TryGetMember always returns an instance of DynamicXMLNode.
/*How do I get the actual value of the XML node? For example, I want the following line to work, but now it throws an  exception.*/

String state = contact.Address.State;

//I have several options here. I can modify the TryGetMember method to return actual values for leaf nodes, for example. //But let’s explore another option: override type conversion. Just add the following method to the DynamicXMLNode class.

public override bool TryConvert(
    ConvertBinder binder, out object result)
{
    if (binder.Type == typeof(String))
    {
        result = node.Value;
        return true;
    }
    else
    {
        result = null;
        return false;
    }
}

/*
Now whenever I have an explicit or implicit type conversion of the DynamicXMLNode type, the TryConvert method is called. The method checks what type the object is converted to and, if this type is String, the method returns the value of the inner XElement. Otherwise, it returns false, which means that the language should determine what to do next (in most cases it means that you’re going to get a run-time exception).

The last thing I’m going to show is how to get access to the XElement methods. Let’s override the TryInvokeMember method so that it will redirect all the method calls to its XElement object. Of course, I’m using the System.Reflection namespace here.
*/

public override bool TryInvokeMember(
    InvokeMemberBinder binder,
    object[] args,
    out object result)
{
    Type xmlType = typeof(XElement);
    try
    {
        result = xmlType.InvokeMember(
                  binder.Name,
                  BindingFlags.InvokeMethod |
                  BindingFlags.Public |
                  BindingFlags.Instance,
                  null, node, args);
        return true;
    }
    catch
    {
        result = null;
        return false;
    }
}

 

Links


Posted by Admin on Tuesday, January 04, 2011 9:58 AM
Permalink | Comments (0) | Post RSSRSS comment feed

Usefull CSS Stylings

1) UnOrdered List with Image

[b]Method 1: Universal Style[/b]

The simplest way to format your lists is to define a style which applies to all lists in the page. In the head of your web page, add the following code:

<style type="text/css">
ul { list-style-image: url("/images/arrow.gif") }
</style>

Syntax: list-style-type: <value>
Possible Values: disc | circle | square | decimal | lower-roman | upper-roman | lower-alpha | upper-alpha | none

Default Value: disc
Applies to: Elements with display value list-item
Inherited: Yes
Specifies the type of list-item marker, and is used if list-style-image is none or if image loading is turned off

Syntax: list-style-image: <value>
Possible Values: <url> | none

Default Value: one
Applies to: Elements with display value list-item
Inherited: Yes
Replaces the marker specified in the list-style-type property.

Syntax: list-style-position: <value>
Possible Values: inside | outside
Default Value: outside
Applies to: Elements with display value list-item
Inherited: Yes
Takes the value inside or outside, with outside being the default. This property determines where the marker is placed in regard to the list item. If the value inside is used, the lines will wrap under the marker instead of being indented.


Eg:

.arrow_li,
.arrow_ul li
{
    list-style-position: outside;
    list-style-image: url(image.axd?picture=/ESOLGroup/Arrow.gif);
    list-style-type: square;
}

 

2) Word-Wrap Property


You can specify either normal or break-word value with the word-wrap property. Normal means the text will extend the boundaries of the box. Break-word means the text will wrap to next line.

.break-word {
  word-wrap: break-word;
}

Without break-word

http://www.webdesignerwall.com_title_with_a_long_url_continue_here

With break-word

http://www.webdesignerwall.com_title_with_a_long_url_continue_here

3) Cross-Browser CSS Gradient

For Webkit Browsers
{
background: -webkit-gradient(linear, left top, left bottom, from(#ccc), to(#000));
}

For Firefox 3.6+
{
background: -moz-linear-gradient(top,  #ccc,  #000);
}

For Internet Explorer
{
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#cccccc', endColorstr='#000000');
}

.demo_gradiant
{
background: #999; /* for non-css3 browsers */

filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#cccccc', endColorstr='#000000'); /* for IE */
background: -webkit-gradient(linear, left top, left bottom, from(#ccc), to(#000)); /* for webkit browsers */
background: -moz-linear-gradient(top,  #ccc,  #000); /* for firefox 3.6+ */
}

Eg:

gradient box

 

4) Links


Categories: css
Posted by Admin on Tuesday, April 20, 2010 12:08 AM
Permalink | Comments (0) | Post RSSRSS comment feed

Tinymce editor Plugin


Posted by Admin on Friday, March 19, 2010 10:54 PM
Permalink | Comments (0) | Post RSSRSS comment feed

How to truncate time from DATETIME in sql 2005

DATEADD(dd, DATEDIFF(dd, 0, GETDATE()), 0)


Categories: SQL 2005
Posted by Admin on Thursday, March 11, 2010 3:26 AM
Permalink | Comments (0) | Post RSSRSS comment feed

File submission/upload -exceeded the maximum length/Size

The form submission cannot be processed because it exceeded the maximum length allowed by the Web administrator. Please resubmit the form with less data.

Step 1: Go to Central Administration - Application Management - Web Application - General Settings and change the Maximum Upload size.
Step 2: If step 1 does not resolve, ensure that you changed the maxRequestLength in the correct web.config. Double-check in IIS for the right virtual directory and the configuration file.
Step 3: Note that the MaxRequestLength is in KB. Do your calculations accordingly.
Step 4: There could more than one web.config files and it could be overridden. Check the appropriate one.
Step 5: refer this KB article.


Categories: MOSS | WSS
Posted by Admin on Wednesday, March 03, 2010 9:52 PM
Permalink | Comments (0) | Post RSSRSS comment feed