Monday, February 29, 2016

jquery


jQuery is a very powerful client-side JavaScript library for Web applications. It provides an lightweight, elegant way to quickly access and manipulate the HTML Document Object Model (DOM), to communicate with server-side web services, and to create animations in the browser without the need for heavier client side technologies.

Overview of jQuery

    • Its History and Features
    • General tips, gotchas, and best practices for ASP.NET Applications
      How can you use jQuery?

    • To provide better user experiences and to create custom controls
    • To ultimately write LESS code
      Sample Controls and Demos

    • Custom Navigation Control
    • jQuery DataTables
    • jQueryValidation
       
      JavaScript has not always been easy or very fun to work with.

  • A large issue with that comes from the various DOM specifications that different browsers used for HTML,  but not the JavaScript itself.
    For the most part, ASP.NET UI Controls help us to avoid working  extensively with the DOM and JavaScript.

  • Example: Server-side PostBack events raised from changes in the state of the page controls.
     
    jQuery
    Write less. Do more.
    Quickly access, manipulate, and traverse HTML documents with a lot LESS effort.
    Microsoft is actively supporting it in MVC3 and the ASP.NET 4 jQuery Templating Engine.
     
     
     
     
     
    Key Features of jQuery
     
    CCS3 Selectors
    Typically you will access elements based on a class or an id,
     but there are also other psuedo-selectors available (:visible, :first, :input). Find all of them here: http://api.jquery.com/category/selectors/
    DOM Manipulation
    This is especially helpful if you need to hide and show elements or when you receive a response from an AJAX response payload.
    Animation
    Utilize a set of built-in jQuery animations or roll your own effects.
     
    AJAX Communication
    Simple HTTP communication interface with JSON and XML based web services.
    Plugins
    There are NUMEROUS open source plugins available for different needs. That being said, be careful what you use.
    Cross Browser Compatibility
    The jQuery codebase regardless of browser.
     
     
     
     
     
     
     
     
     
     
    Prerequisites for jQuery
     
    Get to know CSS and HTML
    If you are trying to animate things or to create your own UI controls, you should understand how CSS and HTML work.
    The biggest things you can learn are how to work with
     position, margin, padding, float, and display properly in HTML.
     
    Learn to love Firebug for Mozilla Firefox
    It is one of the best web developer tools available you don’t have to pay for.
    Learn to think in Sets and Events
    A selector returns a set of element that your jQuery code will operate over
    This will hide all of the H1 tags in your HTML page
     
    $(“h1”).css(“display”,”none”);
     
    Beware operating over LARGE sets, this can cause your browser to become unresponsive or you can even crash your browser.
     
    A elements of the DOM have events which you can subscribe to with event handlers
     
    $ (“a”).click(function(event){
                    alert (“You clicked a link!”);
    });
     
     
     
     
     
    Best Practices
     
    Managing State with AJAX
     
    Selectors for ASP.NET Controls
     
    Debugging Tips
     
     
    Managing State with AJAX
     
    Most tutorials and documentation will prescribe that you initialize all of your jQuery code in an event that handles to document.
     
    function initControls(){
                    //your init code here
    }
     
    $(document).ready(function(){
                     initControls();
    });
     
    However, this becomes a problem when you are using AJAX UpdatePanels, because the $(document).ready() will not fire after the call to the server has been completed.
     
    Any changes that the initControls() function made to the DOM within the UpdatePanel are erased. This includes any event handling you set up.
     
     
    So what is the solution to this problem?
    Sys.WebForms.PageRequestManager to the Rescue!
    This class manages partial-page rendering in ASP.NET pages.
    It comes with client-side events that you can subscribe to.
    var requestManager = Sys.WebForms.PageRequestManager.getInstance();
    function initControls(){
                    //your init code here
    }
    function endRequestHandler(sender, args){
                    initControls();
    }
    $(document).ready(function(){
                    requestManager.add_endRequest(endRequestHandler);
     
                    //still need to do the initial init
                    initControls();
    });
     
    Now we can deal with the UpdatePanel partial-page rendering and still have our jQuery.
     
    Managing State with AJAX
     
    The full list of PageRequestManager events with descriptions:
     

PageRequestManager Event
Description
initializeRequest
Raised before processing of the asynchronous request starts. You can use this event to cancel a postback.
beginRequest
Raised before processing of an asynchronous postback starts and the postback is sent to the server. You can use this event to set request headers or to begin an animation that indicates that the page is processing.
pageLoading
Raised after the response from the server to an asynchronous postback is received but before any content on the page is updated. You can use this event to provide a custom transition effect for updated content.
pageLoaded
Raised after all content on the page is refreshed, as a result of either a synchronous or an asynchronous postback. You can use this event to provide a custom transition effect for updated content.
endRequest
Raised after an asynchronous postback is finished and control has been returned to the browser. You can use this event to provide a notification to users or to log errors.

 

Selectors for ASP.NET Controls

If you need to grab an TextBox by its ID, you would undoubtedly think that this will work just fine:

                $(“#txtBox”)

  • However, it might not always.
  • The Problem: In ASP.NET, the INamingContainer appends identifiers to the controls so that it can uniquely reference a control.
  • To get around this, you can use the following:
                    $("*[id$=‘txtBox']")

  • This will look for all elements (*) with txtBox at the end of it.
  • Keep in mind, that this is not a good solution for controls in a Repeater, but you should be using a class to reference these controls anyways, since they are not unique.
     
    Debugging Tips
    jQuery errors aren’t always the easiest to spot. When a call error occurs, any jQuery and JavaScript below it will not run so that might be your best indicator.
    To debug your code, use Mozilla Firefox in combination with Firebug.

    • Check to make sure all of the files are getting loaded properly.
    • Make sure that you’re not loading libraries twice and that all libraries are loaded in the proper dependency order. jQuery should be your first JavaScript file.
    • Make sure all plugins are in-synch with your chosen jQuery library code.
    • Step through your code in Firebug and use the watch variables. Don’t step into your jQuery code very deeply, because the problem is most likely in your own code.
    • Sometimes, an alert statement is just what you need to glean a better understanding.
       
      Custom Navigation Control
      jQuery DataTables
      jQuery Validation
       
       
       

Thursday, February 25, 2016

oops Interesting....



Interface
Abstract class
we can not declare a static method in an interface, because interfaces have no implementation.
xxxxxx
public interface Iproduct
{
 
static void test();
 
}
xxxxx
declare a method as static in an abstract class,
 
 because abstract classes can have implementations of static methods
ex: public static void test()
 {
 }
Thus by above point :interface cannot implement methods
abstract class can implement methods
An interface cannot contain fields, constructors, or destructors and it has only the property's signature but no implementation.
An abstract class can contain fields, constructors, or destructors and implement properties
Based on above point, we can say ,:Thus a class may inherit several interfaces but only one abstract class.
 
A class implementing an interface has to implement all the methods of the interface
but the same is not required in the case of an abstract Class.
No access modifiers are allowed in Interface
Various access modifiers such as abstract, protected, internal, public, virtual, etc. are useful in abstract Classes




Abstract classes are faster than interfaces.


--------------------------------------


Sealed class


----------------------------------------


 


public sealed class classSealed


 {


 // Class members here.


 public string ID;


 public double Price;


 }


-------------------------------------------------------------------------------------------------


A sealed class cannot be used as a base class.


For this reason, it cannot also be an abstract class.


Sealed classes are primarily used to prevent derivation.


Because they can never be used as a base class, some run-time optimizations can make calling sealed class members slightly faster.


Sealing a method means one cannot override it.


 In C# structs are implicitly sealed; therefore, they cannot be inherited.


 


Ex:Humanàmale class,female class(Here we can say male and female classes are sealed)


public class TestClass : classSealed


 {


 }


 


In C# a method can not be declared as sealed.


However when we override a method in a derived class, we can declare the overridden method as sealed as shown below.


By declaring it as sealed, we can avoid further overriding of this method.


public class testClass


 {


 public int x;


 public int y;


 public virtual void testMethod(){


 }


 }


 public class TestClass: testClass


 {


 public override sealed void testMethod(){


 


 }


 }


-------------------------------------------------------------------------------
Prove that only 1 instance of the object is created for static classes?

static constructor:only one 1 instance of the object is  created then this constructor should run only once.

Static class:we can define static memebers(like public static int icount)

if we invoked the method twice/but constructor will fire only once.

public static class Staticclasses
    {
    public static int icount;
    static Staticclasses()
    {

    }
    static void somemethod()
    { }

    }

What is the use of private constructor ? This is used for utility classes

1.a class with a private constructor can not be inherited

2. we can not create a object of the class which has private constructor
3. many times we do not want to create instances of certain classes like utility ,common routine classes



public class class1
{
private class1()
{
}
public static string getdata()
{
return "hello"
}
}

Client can use by using:

string str=class1.getdata()  (SO we are not create instance,we can access method)


Can we define abstract class as a static?

never forget  we can never define abstract class as static



What is the use of c# (Csharp) Shadowing ?

shadowing is replaces current element of the parent where as override is replace the implementations(it does not replace data type or (datatype /datamethod)



Abstraction_Encapsulation:
namespace Abstract_encapsulation
{
    public class customer
    {
        //step1:what does customer(Abstraction)//show only what is neccessary
        //step2:How(Validate,createdbobjects)
        //step3:made complicated method as private (Encapuslation):means reduce the complexity/hide complexity to client

        public string customercode = "";
        public string customername = "";
        //public void Add()
        //{

        //}

        //Granular


        //public bool validate()
        //{
        //    //cust code and name
        //    return true;
        //}
        //public bool createDbobjects()
        //{
        //    return true;
        //}


        //Now simplified to expose to clients

        public void Add()
        {
            validate();
            createDbobjects();
        }
        private bool validate()
        {
            //cust code and name
            return true;
        }
        private bool createDbobjects()
        {
            return true;
        }

    }
}

Inline image 1

Inline image 2

Friday, November 21, 2014

MCTS SSIS 2012 Implementing a Data Warehouse

  1. Lesson 1: Implementing Dimensions and Fact Tables
    1. Creating a Data Warehouse Database
    2. Implementing Dimensions
    3. Implementing Fact Tables
      1. Practice: Implementing Dimensions and Fact Tables
    4. Lesson Summary
    5. Lesson Review
  2. Lesson 2: Managing the Performance of a Data Warehouse
    1. Indexing Dimensions and Fact Tables
    2. Indexed Views
      1. Using Appropriate Query Techniques
    3. Data Compression
    4. Columnstore Indexes and Batch Processing
      1. Practice: Loading Data and Using Data Compression and Columnstore Indexes
    5. Lesson Summary
    6. Lesson Review
  3. Lesson 3: Loading and Auditing Loads
    1. Using Partitions
    2. Data Lineage
      1. Practice: Performing Table Partitioning
    3. Lesson Summary
    4. Lesson Review
  4. Case Scenarios
    1. Case Scenario 1: Slow DW Reports
    2. Case Scenario 2: DW Administration Problems
  5. Suggested Practices
    1. Test Different Indexing Methods
    2. Test Table Partitioning

Lesson Summary
  1. Lesson 1: Implementing Dimensions and Fact Tables

■■ In this lesson, you learned about implementing a data warehouse.
■■ For a data warehouse database, you should use the Simple recovery model.
■■ When creating a database, allocate enough space for data files and log files to prevent autogrowth of the files.
■■ Use surrogate keys in dimensions in which you expect SCD Type 2 changes.
■■ Use computed columns.
Lesson Review
1. Which database objects and object properties can you use for autonumbering?
(Choose all that apply.)
A. IDENTITY property
B. SEQUENCE object
C. PRIMARY KEY constraint
D. CHECK constraint
2. What columns do you add to a table to support Type 2 SCD changes? (Choose all that
apply.)
A. Member properties
B. Current row flag
C. Lineage columns
D. Surrogate key
3. What is an inferred member?
A. A row in a fact table added during dimension load
B. A row with aggregated values
C. A row in a dimension added during fact table load
D. A computed column in a fact table
Answers:
Lesson 1
1. Correct Answers: A and B
A. Correct: The IDENTITY property autonumbers rows.
B. Correct: You can use the new SQL Server 2012 SEQUENCE object for
autonumbering.
C. Incorrect: Primary keys are used to uniquely identify rows, not for
autonumbering.
D. Incorrect: Check constraints are used to enforce data integrity, not for
autonumbering.
2. Correct Answers: B and D
A. Incorrect: Member properties are dimension columns used for additional information
on reports only.
B. Correct: You need a current flag for denoting the current row when you implement
Type 2 SCD changes.
C. Incorrect: Lineage columns are used, as their name states, to track the lineage
information.
D. Correct: You need a new, surrogate key when you implement Type 2 SCD changes.
3. Correct Answer: C
A. Incorrect: You do not add rows to a fact table during dimension load.
B. Incorrect: You do not create rows with aggregated values.
C. Correct: A row in a dimension added during fact table load is called an inferred
member.
D. Incorrect: A computed column is just a computed column, not an inferred member.


■■ In this lesson, you learned how to optimize data warehouse query performance.
■■ In a DW, you should not use many nonclustered indexes.
■■ Use small, integer surrogate columns for clustered primary keys.
■■ Use indexed views.
■■ Use columnstore indexes and exploit batch processing.
Lesson Review
1. Which types of data compression are supported by SQL Server? (Choose all that apply.)
A. Bitmap
B. Unicode(my word it automatically applied when u choose row or page compression)
C. Row
D. Page
2. Which operators can benefit from batch processing? (Choose all that apply.)
A. Hash Join
B. Merge Join
C. Scan
D. Nested Loops Join
E. Filter
3. Why would you use indexed views? (Choose all that apply.)
A. To speed up queries that aggregate data
B. To speed up data load
C. To speed up selective queries
D. To speed up queries that involve multiple joins

Answers:
1. Correct Answers: B, C, and D
A. Incorrect: SQL Server does not support bitmap compression.
B. Correct: SQL Server supports Unicode compression. It is applied automatically
when you use either row or page compression.
C. Correct: SQL Server supports row compression.
D. Correct: SQL Server supports page compression.
2. Correct Answers: A, C, and E
A. Correct: Hash joins can use batch processing.
B. Incorrect: Merge joins do not use batch processing.
C. Correct: Scan operators can benefit from batch processing.
D. Incorrect: Nested loops joins do not use batch processing.
E. Correct: Filter operators use batch processing as well.
3. Correct Answers: A and D
A. Correct: Indexed views are especially useful for speeding up queries that aggregate
data.
B. Incorrect: As with any indexes, indexed views only slow down data load.
C. Incorrect: For selective queries, nonclustered indexes are more appropriate.
D. Correct: Indexed views can also speed up queries that perform multiple joins.


■■ Table partitioning is extremely useful for large fact tables with columnstore indexes.
■■ Partition switch is a metadata operation only if an index is aligned with its base table.
■■ You can add lineage information to your dimensions and fact tables to audit changes
to your DW on a row level.
Lesson Review
1. The database object that maps partitions of a table to filegroups is called a(n)
A. Aligned index
B. Partition function
C. Partition column
D. Partition scheme
2. If you want to switch content from a nonpartitioned table to a partition of a partitioned
table, what conditions must the nonpartitioned table meet? (Choose all that apply.)
A. It must have the same constraints as the partitioned table.
B. It must have the same compression as the partitioned table.
C. It must be in a special PartitionedTables schema.
D. It must have a check constraint on the partitioning column that guarantees that all
of the data goes to exactly one partition of the partitioned table.
E. It must have the same indexes as the partitioned table.
3. Which of the following T-SQL functions is not very useful for capturing lineage
information?
A. APP_NAME()
B. USER_NAME()
C. DEVICE_STATUS()
D. SUSER_SNAME()

Test Table Partitioning
In order to understand table partitioning thoroughly, you should test it with aligned and
nonaligned indexes.
■■ Practice 1 Partition the FactInternetSales table in the AdventureWorkDW2012 sample
database. Create aligned nonclustered indexes on all foreign keys of the fact table
included in joins of the query from the previous practice. Run the query and check the
execution plan.
■■ Practice 2 Create nonaligned nonclustered indexes on all foreign keys of the fact
table included in joins of the query from the previous practice. Run the query and
check the execution plan again.

Answers:
1. Correct Answer: D
A. Incorrect: Aligned indexes are indexes with the same partitioning as their base
table.
B. Incorrect: The partition function does logical partitioning.
C. Incorrect: The partition column is the column used for partitioning.
D. Correct: The partition scheme does physical partitioning.
2. Correct Answers: A, B, D, and E
A. Correct: It must have the same constraints as the partitioned table.
B. Correct: It must have the same compression as the partitioned table.
C. Incorrect: There is no special schema for partitioned tables.
D. Correct: It must have a check constraint to guarantee that all data goes to a single
partition.
E. Correct: It must have the same indexes as the partitioned table.
3. Correct Answer: C
A. Incorrect: The APP_NAME() function can be useful for capturing lineage
information.
B. Incorrect: The USER_NAME() function can be useful for capturing lineage
information.
C. Correct: There is no DEVICE_STATUS() function in T-SQL.
D. Incorrect: The SUSER_SNAME() function can be useful for capturing lineage
information.