Showing posts with label C#. Show all posts
Showing posts with label C#. Show all posts

Wednesday, 16 October 2019

Publish your project in visual studio

You need to click on the Build menu and then select Publish ,



Once the Dialog has been open you need to specify the publishing target , Since we choose the file system so we need to click on "Folder", Then we gonna need to specify the target location for that
but visual studio will choose a default location as well after getting done with that you just simply need to click on "Publish" button and It's done! Now you can pick the published code from your chosen target location and can deploy it as you want.



Tuesday, 15 October 2019

Adding jQueryUI library in MVC Project

First you need to download JqueryUI via their website or Nuget Package manager, Once you get it in your project you need to add it into BundleConfig.cs file like below:

    public class BundleConfig
    {
        public static void RegisterBundles(BundleCollection bundles)
        {

            bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
            "~/Scripts/jquery-ui-{version}.js"));
        }
    }

Now you can add it in your _Layout page :

   @Scripts.Render("~/bundles/jqueryui")         



Monday, 2 March 2015

Drop Down Data Binding in Asp.Net


DataTable data = GetData();
ddrLocationList.DataSource = data;
ddrLocationList.DataTextField = "Name";
ddrLocationList.DataValueField = "ID";
ddrLocationList.DataBind();


Wednesday, 5 March 2014

#region in Visual Studio

It allows block of code to expand or collapse when using the outlining feature of the Visual Studio Code Editor. You can write namespaces, classes, methods, interfaces, delegates, events inside it.

#region MyRegion

//  Namespaces
//  Classes
//  Methods
//  Interfaces
//  Delegates
//  Events

#endregion


Thursday, 27 February 2014

Wednesday, 26 February 2014

Get type information of any object using GetType( )

object obj = new object();
obj.GetType();

string s;
s.GetType();

List<string> StringList = new List<string>();
StringList.GetType();


Tuesday, 25 February 2014

Concatenate Dictionary objects in c#

Dictionary<string, object> d1 = new Dictionary<string, object>();
d1.Add("Name","Talha");
Dictionary<string, object> d2 = new Dictionary<string, object>();
d2.Add("City","Lahore");

// --- Now Concatenate Both Dictionaries using concat Extension method
d1 = d1.Concat(d2).ToDictionary(x=> x.Key , x=> x.Value);

Note:  Here "Concat" is an Extension method  so You have to include it’s Namespace reference on top.

i.e.
using System.Linq;

Friday, 14 February 2014

Boxing and Unboxing in c#

Boxing:

int i = 123;
object o = i;  // boxing interger i into object o.

Unboxing:

object o = 123;
i = (int)o;  // unboxing int value from object o to int i.


Thursday, 23 January 2014

Friday, 26 July 2013

Caching in Asp.net C#

.NET provides three primary forms of caching:

       page level output caching                                                        easy to implement
        user control level output caching (or fragment caching)         easy to implement 
       Using  Cache Object                                            More flexible throughout every layer of an application

1.   Page Level Output Caching
The simplest form of caching, output caching simply keeps a copy of the HTML that was sent in response to 
a request in memory. Subsequent requests are then sent the cached output until the cache expires, resulting in

 potentially very large performance gains (depending on how much effort was required to create the original page output—sending cached output is always very fast and fairly constant).
You have to give the duration in seconds for the page to be cached.

Implementation:
          <%@ OutputCache Duration="60" VaryByParam="*" %>
This directive, as with other page directives should appear at the top of the ASPX page, before any output.


2.   Fragment Caching, User Control Output Caching
Often, caching an entire page is not feasible, because certain parts of the page are customized for the user.