header1.html

Sunday, 21 September 2014

'Thread was being aborted' –Exception for Response.Redirect() method inside try-catch block

If you are monitoring errors of your application you might have noticed that in your error log file lots of 'Thread was being aborted' exception logged.
This Exception occurs when you use Response.Redirect inside of a Try / Catch block. Your code will work and the browser will be redirected but that is reason of getting lots of alerts.
If you are passing QueryString then your application may not work properly because of this issue, so it is important to handle or avoid this kind of exceptions.
There are different ways to resolve this issue,

  • Simplest way to move the Response.Redirect outside the Try/Catch block. 
  • Catch Exception and do nothing, 
                 try 
                    { 
                        if (Condition) 
                          Response.Redirect("newpage.aspx”); 
                    } 
                catch (ThreadAbortException ex) 
                 { // do nothing } 
                 catch (Exception e) 
                  { //Write your Error log logic } 
  • Use overload of Redirect method like, Pass false as second parameter to this overload. Response.Redirect("newpage.aspx”,false); 
I prefer to use 3rd approach as it is easiest one to implement and it works fine in case if you are using QueryString in your application.

Hope this helps you someway. Thank you!!!

Sunday, 20 July 2014

What is XSLT?How to Transform XML data using XSLT?

In this post we are going to discuss about-How we can display XML content?There are multiple ways to do to so,but XSLT is best suitable way.So,what is XSLT?

To know about XSLT: Extensible Stylesheet Language Transformation, we should have the basic idea of following,

What is a Markup Language?

A language specially designed for processing, defining and presenting text/data is called a Markup Language.

To know about XSLT, we should have the basic idea of following.

There are three languages in XSL family,

  1. XSL Transformations(XSLT): XML language for transforming XML Documents.
  2. XSl  Formatting Objects (XSL-FO):XML language for specifying the visual formatting of an XML document.
  3. XML Path Language (XPATH): a non XML language used by XSLT, and also available for use in non-XSLT contexts, for addressing the parts on an XML document.

  • XSLT helps to transform one XML document to another. Output of XSL transformation can be another XML, HTML or PDF. Data from one XML can be read and modified into another applying arithmetic, numeric, string operations based on the need.
  • XSLT was developed by W3C especially for XML. XSLT internally uses XPATH and XSL-FO for navigating, performing calculation and for formatting the data.
  • XSLT documents are well-formed XML documents that describe how another XML document should be transformed. For XSLT to work, it needs an XML document to transform and an engine to make the transformation take place. In addition, parameters can be passed in to XSLTs providing further instructions on how to do the transformation.
Why and where is it used?

In web application, web services sent the business data in form of XML within the Applications and across the applications. Since XML is accepted as the most common mode of storing and passing data, a language is needed to read the XML in different ways for different application.


A medium like XSLT is needed to parse the data from XML and give it to browsers to render the HTML code. XSLT works in between XML and Browser to transform the data.


Example:

Blog.xml

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="BlogsStyle.xsl"?>
<Blogs>
       <name id="21">
                <bname>Career Web Helper</bname>
                <Topics>Online Quizzes,MCQs and Articles on Microsoft Technologies.</Topics>
       </name>
                   <place>Pune</place>
                   <language>English</language>
</Blogs>

BlogsStyle.xsl

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'>
<xsl:output method="html" indent="yes" omit-xml-declaration="yes" encoding="utf-8"/>
<xsl:template match="Blogs">
<html>
<body>
   <h2>Blog Detail</h2>
   <table border="1">
     <tr>
       <td bgcolor="gray">Blog Id</td>
       <td><xsl:value-of select="name/@id"/></td>
     </tr>
     <tr>
       <td bgcolor="gray">Blog Name</td>
       <td><xsl:value-of select="name/bname"/></td>
     </tr>
      <tr>
       <td bgcolor="gray">Topics Covered</td>
       <td><xsl:value-of select="name/Topics"/></td>
     </tr>
     <tr>
       <td bgcolor="gray">Place</td>
       <td><xsl:value-of select="place"/></td>
     </tr>
     <tr>
       <td bgcolor="gray">Language</td>
       <td><xsl:value-of select="language"/></td>
     </tr>
   </table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

Output:

Sample Basic XSLT Example

This is only basic of XSLT,we will cover some advance topics in upcoming posts. Hope you like this post. 


Saturday, 26 April 2014

JavaScript Quiz


JavaScript Quiz
1.Which of the following is not an event in JavaScript?
onunload
onremove
ondblclick
onchange


2.True or False-"All variables are of object type in JavaScript".
True
False


3.What will be o/p of "2"+2+1 JavaScript statement?
5
221
23
Error


4.What Built-in javascript function back() does?
Returns to previous function
Closes the specified window
Returns to the previous URL
No such function


5. A ________ box allows the user to enter input by providing a text box.
confirm
prompt
alert
drop


6.Which of the following looping structure is not available in JavaScript ?
for
while
do-while
foreach


7.The Undefined value Javascript means the variable used in code doesn't exist or is not assigned any value or the property doesn't exist.Ture or False?
Ture
False


8.How to disable an HTML object using JavaScript?
document.getElementById("myObject").visible = false;
document.getElementById("myObject").disabled = true;
document.getElementById("myObject").visibility = false;
document.getElementById("myObject").disable = true;


9.It is easy to manipulate cookies in JavaScript with the document.cookie property.True/False?
True
False



10.What will be o/p of 2+1+"3" JavaScript statement?
213
6
33
Error


Sunday, 26 January 2014

Javascript MCQs(Multiple Choice Questions)


Hello All first I would like to Wish you all Happy New year 2014,so before going to new post here are some last years Successful popular posts,
1)CRUD operation using Entity Framework and LINQ
2)Basic Web Development MCQs
3)New Features of VS 2013 Developers Perspective
4)WCF Online Quiz or WCF MCQs
and many more are there so please visit them and do share,like & comment on it.
1.What will be result of following javascipt function
<script type="text/javascript">
var name = "CareerWebHelper";
function DisplayName () {
var name = "Sagar"; 
document.write(name); 
}
</script>
A.CareerWebHelper
B.Sagar
C.Error
D.None of above
Click for answer 

B.Sagar
2.What will be result of following javascipt function
<script type="text/javascript">
var name1 = "WCF MCQs";
function DisplayName () {
var name2 = " Online"; 
document.write(name1+name2); 
}
</script>
A.WCF MCQsOnline
B.WCF MCQs Online
C.Object required error
D.Javascript Error
Click for answer 

B.WCF MCQs Online
3.What will be result of following javascipt function?
<script type="text/javascript">
var name1 = "WCF quiz";

function DisplayName () {
 var name2 = "ASP.NET MCQs";
if(name1 != "") 
document.write(name1);
else
document.write(name2);
 
}
</script>
A.Javascript Error at else statement
B.ASP.NET MCQs
C.WCF quiz
D.Javascript Error in if condition
Click for answer 

C.WCF quiz
4.What will be result of following javascipt function?
<script type="text/javascript">
var name1 = "WCF quiz";

function DisplayName () {
 var name2 = "ASP.NET MCQs";
 (name1 != ""?document.write(name2):document.write(name1));
}
</script>
A.WCF quiz
B.ASP.NET MCQs
C.Javascript Error near conditional statement
D.Nothing will happen
Click for answer 

B.ASP.NET MCQs
5.What will be result of following javascipt function?
<script type="text/javascript">
var name1 = "";

function DisplayName () {
 var name2 = "ASP.NET MCQs";
 if(name1 = "")
document.write("name1 is null");
else
document.write(name2);
 
}
</script>
A.name1 is null
B.Error near name1 declaration
C.No result
D.ASP.NET MCQs
Click for answer 

D.ASP.NET MCQs
6.What will be result of following javascipt function?
<script type="text/javascript">
var name1 = "WPF Quiz";

function DisplayName () {
 var name2 = "ASP.NET MCQs";
 if(name1 = "WPF Quiz")
document.write("name1 is not null");
else
document.write(name2);
 
}
</script>
A.ASP.NET MCQs
B.Error near if statement
C.name1 is not null
D.None of above
Click for answer 

C.name1 is not null
7.What will be result of following javascipt function?
<script type="text/javascript">
var name1 = "WPF Quiz";

function DisplayName () {
 var name2 = "ASP.NET MCQs";
 (name1.replace('P','C')=="WCF Quiz"?document.write(name1):document.write(name2));
}
</script>
A.WPF Quiz
B.WCF Quiz
C.ASP.NET MCQs
Click for answer 

A.WPF Quiz
8.What will be result of following javascipt function?
<script type="text/javascript">
var name1 = "WPF Quiz";
function DisplayName () {
 var name2 = "ASP.NET MCQs";
 name1=name1.replace('P','C');
 document.write(name1);
}
</script>
A.WCF Quiz
B.WPF Quiz
C.ASP.NET MCQs
D.Error in statement near replace()
Click for answer 

A.WCF Quiz

Monday, 23 December 2013

New features in Visual Studio 2013 Developers perspective


    Hello All this is my third Article in this blog.Although main Objective of this Blog is to provide set of Online Quizzes and MCQs on Microsoft Technologies & Basics of Computers but after successful response to my Article- CRUD operation using Entity Framework and LINQ
some of my friends suggested me write few more articles and I am happy for that ☺☺☺.
This post is all about new features in Visual Studio 2013 IDE which I like most, We are happy for how Microsoft is managing the excellency in products like .NET Framework,Visual Studio,Windows and many more.
Visual Studio 2013 has new and enhanced features like,
1)Visual Studio languages      2).NET Framework 4.5.1
3)TFS and ALM                   4)SharePoint and Office
5)LightSwitch                        6)Windows Azure Mobile Services etc.etc. but in this post I am not going to discuss all the above.
Here we are going to discuss about Developers perspective of Visual studio 2013 for innovative features for greater productivity,
Following features which I like the most ☺☺☺...
1)Peek Definition(Alt+F12)
2)Move Code Line Up/Down (Alt+Arrow)
3)Inline Navigate To OR Code Lens(Ctrl+,)
4)64bit Edit and Continue
5)Back to Origin (i.e. icon colors)

Features like TFS&ALM(Team Foundation Server & Application Lifecycle Management)are fabulous in VS2013 as they made Developers or Support Team's life very easy for managing applications from Development phase till production deployment.
VS2013 also helps in Agile Portfolio Management for the Projects which are following Agile/Srum methodology of development.
So lets start with our favorite features ☺,
1)Peek Definition:
While coding most of developers are unhappy with F12(Go TO Definition) as after continuous clicking F12 they are getting lost from where they started or what they want actualy :P ,but that problem is getting resolved in this new IDE VS2013 ☺, now we can see the definition on the same file with new window as follow,
sagarphalke.blogspot.com

2)Move Code Line Up/Down:
This is very cool feature added in VS2013,with key (Alt+Arrow) we can move code segment Up or Down with arrow keys.
It will really help in performance improvement for Developers.
3)Inline Navigate To OR Code Lens:
Using this feature (ALT + ,) we can easily check the history of file as it is directly synched with TFS,so this feature can check who worked on this file by checking changeset.We can also check test cases passed/failed for particular code snippet.
new features in VS2013

This feature is helpful for Developers to find References,Find history and also in UTC executions.

4)64bit Edit and Continue:
It enables you to make changes to your source code while your program is in break mode but previous IDE were throwing exceptions for 64 bit,but now VS2013 IDE enables Edit and Continue for 64-bit and support for asynchronous debugging.
new features in Visual Studio 2013

5)Back to Origin:
This is last but very important feature I like as all of us were complaining about Color and Themes of VS2012.
This new IDE is having good themeing functionality and decent color schemes ☺,here we can see light color icons compare to VS2012.
Here I have listed some cool features which I like most but you can find many new features added in VS2013 which are helpful in developers productivity.
Conclusion:
In this article we have seen some cool features of Visual Studio 2013 which helps in improvement of Developers productivity. I hope this post will help you.
Happy Development!!!☺☺☺

Friday, 29 November 2013

MCQs on MVC in .NET(Quiz-1)



MVC_MCQs
This Post is basicaly to fill some Coming Soon Content of Quizzes.I was planning for long time to cover MVC topic,but due to some reasons it was not happened.So today am here with some simple questions by taking some reference of MCTS 70515 exam.
Please take this Simple quiz and try to solve some more Quizzes here.
Quiz-(1):MVC 2.0 in .NET
1.If you have View with @Page directive to inherit from ViewPage<TModel> then your View is_________.(where TModel is typpe of Model)
Partial View
Strongly Typed View
Content View
Template View


2.You are writing an action method called AddProduct inside the Product controller. The logic in your code indicates that you need to call the Cart controller’s Add method as a result of your controller’s action method. Which line of code would accomplish this?
return Content("Cart.Add")
Response.Redirect("Cart.aspx?Add")
return redirect("Cart/Add")
return View("Cart.Add")


3.You are implementing an ASP.NET MVC 2 Web application. The URL with path /Home/Details/{country} will return a page that provides information about the named country. You need to ensure that requests for this URL that contain an unrecognized country value will not be processed by the Details action of HomeController.What should you do?[REF:70-515]
Add the ValidateAntiForgeryToken attribute to the Details action method.
Add the Bind attribute to the country parameter of the Details action method. Set the attribute's Prefix property to Country.
Create a class that implements the IRouteConstraint interface. Configure the default route to use this class.
Create a class that implements the IRouteHandler interface. Configure the default route to use this class.


4.You create an ASP.NET MVC 2 Web application that contains the following controller class. public class CartController : Controller { static List products = new List(); public ActionResult Index() { return View(); }} and the Views folder of your application, you add a view page named Index.aspx that includes the following @ Page directive.<%@ Page Inherits="System.Web.Mvc.ViewPage" %> You test the application with a browser. You receive the following error message when the Index method is invoked: "The view 'Index' or its master was not found." You need to resolve the error so that the new view is displayed when the Index method is invoked.What should you do?
Create a folder named Cart inside the Views folder.Move Index.aspx to the Cart folder.
Modify the Index method by changing its signature to the following: public ActionResult Index(Cart c)
Change the name of Index.aspx file to Cart.aspx
None of above


5.You are developing an ASP.NET MVC 2 application. A view contains a form that allows users to submit their first name. You need to display the value that is submitted, and you must ensure that your code avoids crosssite scripting. Which code segment should you use?
<% Response.Write(HttpUtility.HtmlDecode(Model.FirstName)) %>
<%: Model.FirstName %>
<%= Model.FirstName %>
Both b&c will work


6.Which of the following statement is false about MVC in .NET?
Complete control over your HTML Markup
Makes Test Driven Development (TDD) very difficult
Allows you to create SEO-friendly URLs for your site
Enables rich AJAX and jQuery integration


7.The Controller class is responsible for the following processing stages:
Locating the appropriate action method to call and validating that it can be called.
Getting the values to use as the action method's arguments.
Handling all errors that might occur during the execution of the action method.
All of the above.


8.Which Helper Method is used to return a user-defined content type.
Content
JavaScript
View
RedirectToRoute


9.Which Helper Method Returns binary output to write to the response?
Content
File
JavaScript
Json


10.Which Action Result Renders a partial view, which defines a section of a view that can be rendered inside another view?
ContentResult
RedirectResult
PartialViewResult
None of above.


Conclusion:Here we saw some simple questions about MVC like ActionResults,Basics of Routing and View.
Next post we are going to cover some tricky questions.Please take your some time to write review about the Quiz.

Saturday, 19 October 2013

Online Quiz on State Management in ASP.NET



While working in WEB Envrionment with HTTP Protocol it becomes challenging to manage state of web applications as HTTP is stateless protocol. But,State management techniques in ASP.NET are used to maintain user state throughout the application. State management becomes essential while learning WEB Application development,let's have look on how many techniques are there to achieve this,
Main techniques are,
a.Client Side
b.Server Side
c.SQL Server State Management

Client Side State Management Techniques:

  1. ViewState
  2. Hidden fields
  3. Query strings
  4. Cookies
  5. Control state</>

Server Side State Management Techniques:

  1. Application State
  2. Session State
  3. Profile Properties
  4. Database support

In this post I am not going to explain above techniquies in detail rather than I am writing Quiz for above topic to test your knowledge about that.Now you might be thinking that how we will test programming knowledge with Quiz,I know we can test our programming knowledge while actual development/work but we should be aware of the topic what we are going to implement,what is syntax?Is there any impact of your implementation on existing application?what will be performance impact?

So,let's take this simple quiz... ☻☻☻

State management in ASP.NET
1.Which of the following is best approach to maintain state of control on client side across rount-trip of page?
Hidden control
ViewState
Session variable
State property


2. A __________ is a small amount of data that is stored either in a text file on the client file system or in-memory in the client browser session.
View State
Control state
Cookie
Session


3.a.Use when you are transferring small amounts of information from one page to another and security is not an issue.
b.You can use this approach only if you are requesting the same page, or another page via a link.
Which of following is recommended techniques?

Query String
ViewState
Session state
Control state


4.Use __________ when you need to store small amounts of information for a page that will post back to itself or to another page, and when security is not an issue.
Query String
Control state
ViewState
Hidden Fields


5.ASP.NET provides application state via the _______________ class as a method of storing global application-specific information that is visible to the entire application.
HttpApplicationState
HttpSessionState
ApplicationState
SessionState


6.ASP.NET provides a session state, which is available as the ____________ class, as a method of storing session-specific information that is visible only within the session.
HttpApplicationState
HttpSessionState
ApplicationState
SessionState


7.Use ___________ state management technique,when you are storing infrequently changed, global information that is used by many users, and security is not an issue and do not store large quantities of information in application state.
Session State
ViewState
Application State
Profile properties


8.Use_____ state management technique,when you are storing user-specific information that needs to be persisted after the user session is expired and needs to be retrieved again on subsequent visits to your application.
Application State
Profile properties
ViewState
Session State


9.Use_____ state management technique,when you are storing large amounts of information, managing transactions, or the information must survive application and session restarts. Also Data mining is a concern, and security is an issue.
Application state
Session state
Database support
None of these


10.Which of the following is not Server side state management technique?
Control State
Application State
Session State
Profile properties

Wednesday, 2 October 2013

WCF MCQs


WCF is framework used to implement SOAs.After some sample quizzes on WCF like
WCF SET-I
WCF SET-II
WCF SET-III
Here I am with some MCQs on WCF again for uncovered topics like Binding,Contracts.


1._________defines the parameters and return type of an operation.
A.Message contract
B.Data contract
C.Fault contract
D.Operation contract
Click for answer 

D.Operation contract.
2._________an endpoint exposed by the application and that corresponds to a service contract implemented by the application.
A.infrastructure endpoint
B.application endpoint
C.binding
D.None of above
Click for answer 

B.application endpoint
3.It is a procedure defined in a service's code that implements the functionality for an operation.
A.operation contract
B.hosting
C.service operation
D.None of these.
Click for answer 

C.service operation
4.___________ is service that runs within a process application that the developer created.
A.hosted service
B.self-hosted service
C.self service
D.Data service
Click for answer 

B.self-hosted service
5.A secure and interoperable binding that is designed for use with duplex service contracts that allows both services and clients to send and receive messages.
A.WSHttpBinding
B.WS2007HttpBinding
C.WSHttpContextBinding
D.WSDualHttpBinding
Click for answer 

D.WSDualHttpBinding
6.Represents an interoperable binding that supports distributed transactions and secure, reliable sessions.
A.NetTcpBinding
B.WSDualHttpBinding
C.WSHttpBinding
D.NetNamedPipeBinding
Click for answer 

C.WSHttpBinding
7.Represents a queued binding that is suitable for cross-machine communication.
A.NetMsmqBinding
B.WSHttpBinding
C.NetNamedPipeBinding
D.HttpPipeBinding
Click for answer 

A.NetMsmqBinding
8.Represents a binding that a Windows Communication Foundation (WCF) service can use to configure and expose endpoints that are able to communicate with ASMX-based Web services and clients.
A.BasicHttpBinding
B.WSHttpBinding
C.NetMsmqBinding
D.NetNamedPipeBinding
Click for answer 

A.BasicHttpBinding

Tuesday, 24 September 2013

MCQs on WinForms in .NET


After good response to C# 4.0 MCQs,I planned to write this post for advanced controls in WinForms.

1.____________ class represents a collection of TreeNode objects.
A.TreeNodes
B.TreeView
C.Collection
D.TreeNodeCollection
Click for answer 

D.TreeNodeCollection
2.The Windows Forms__________control displays a hierarchy of nodes, like the way files and folders are displayed in the left pane of the Windows Explorer feature in Windows operating systems.
A.ContextMenuStrip
B.TreeView
C.Splitter
D.ToolStrip
Click for answer 

B.TreeView
3.______ class represents a node of a TreeView.
A.Node
B.TreeNodeCollection
C.TreeNode
D.None of above
Click for answer 

C.TreeNode
4.Windows Forms _________ controls are used to resize docked controls at run time.
A.Timer
B.Splitter
C.ContextMenuStrip
D.None of above
Click for answer 

B.Splitter
5.________ class represents a control consisting of a movable bar that divides a container's display area into two resizable panels.
A.Splitter
B.Container
C.ContextMenuStrip
D.SplitContainer
Click for answer 

D.SplitContainer
6.The Windows Forms __________ is a component that raises an event at regular intervals.
A.Splitter
B.delegate
C.Timer
D.None of these
Click for answer 

C.Timer
7.The __________ control provides a shortcut menu that you associate with a control.
A.ContextMenuStrip
B.ToolStrip
C.ToolStripTextBox
Click for answer 

A.ContextMenuStrip
8.ContextMenuStrip replaces _______.
A.ContextMenu
B.MenuStrip
C.ToolStrip
D.Menu
Click for answer 

A.ContextMenu

Friday, 16 August 2013

CRUD operation using Entity Framework and LINQ



This article is for beginners who are new to EF Terminology and currently working on ADO.NET by creating DAL,BAL to interact with database.
First question comes in to picture is What is Entity Framework?
Lets see the definition given by Microsoft-"The Microsoft ADO.NET Entity Framework is an Object/Relational Mapping (ORM) framework that enables developers to work with relational data as domain-specific objects, eliminating the need for most of the data access plumbing code that developers usually need to write. Using the Entity Framework, developers issue queries using LINQ, then retrieve and manipulate data as strongly typed objects. The Entity Framework’s ORM implementation provides services like change tracking, identity resolution, lazy loading, and query translation so that developers can focus on their application-specific business logic rather than the data access fundamentals."
So,Entity Framework is ORM(Object/Relational Mapping) framework.
ORM helps to keep database design separate from domain Class design and it also improves standard CRUD (Create, Read, Update & Delete)operation.
Entity Framework 4.1 have multiple modeling techniques like code first, model first or database first.Here we are going to implement Database first approach. In this article we are also going to implement LINQ(Language Integrated Query)to perform CRUD operation with entity model.
To implement Database/Model first approach we need to create database first,
Query to create Database in SQL Server:

CREATE DATABASE MYCART

Query To create PRODUCTS table in MYCART Database:

USE MYCART
CREATE TABLE PRODUCTS
(
 Product_ID int IDENTITY(100,1) NOT NULL primary key,
 Product_Name varchar(20),
 Product_Desc varchar(50),
 Product_Price money,
 Quantity int
)

Create New ASP.NET Application:Create application "EF_CRUD" and add AddProduct.aspx page to implement CREATE operation.
structureCareerWebHelper
Sample Structure

Create the First simple Entity Data Model (EDM):
Solution Explorer =>right click on project => Add => New Item. Select the Data Template => ADO.NET Entity Data Model and click Add.
edmx

Rename it as ProductModel.edmx

It opens Entity Data Model Wizard. Select "Generate from database" option and click "Next"

Now enter your credentials and your database details as follows.
CareerWebHelperEM

StepsEF

By double clicking on ProductModel.edmx, it will open EDM designer which displays all the entities for selected tables and relation between them.Now check Entity model will be generated like
ProductModel

CREATE/INSERT Operation:Check AddProduct.aspx.cs ---Download
Create instance of Context MYCARTEntities context = new MYCARTEntities();
protected void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {

                PRODUCT objProduct = new PRODUCT();
                objProduct.Product_Name = txtName.Text;
                objProduct.Product_Desc = txtPdesc.Text;
                objProduct.Product_Price = decimal.Parse(txtPrice.Text);
                objProduct.Quantity = int.Parse(txtQuantity.Text);

                context.AddToPRODUCTS(objProduct);
                int result=context.SaveChanges();
                if (result != 0)
                {
                    lblMsg.Text = "Product Added!!";  
                }
                else
                {
                    lblMsg.Text = "Failed!!";
                }
                

            }
            catch (Exception ex)
            {

                lblMsg.Text = "Failed!!";
                throw ex;
            }
        }

SaveChanges() method on the context to reflect the changes back to database.This will insert the record into the table.

Now, READ,UPDATE and DELETE OPERATION:1.Add ModifyProduct.aspx page to Project
2.Add GridView to page "gvModifyProducts"
3.Use Template fields and Bound Fields to bind Data to GridView.
4.Create following Method to implement READ Operation
private void BindProductDetails()
        {
            try
            {
                var myData = from c in context.PRODUCTS select new { c.Product_ID, c.Product_Name, c.Product_Desc,       c.Product_Price,c.Quantity };
                gvModifyProducts.DataSource = myData;
                gvModifyProducts.DataBind();
            }
            catch (Exception ex)
            {
                
                throw ex;
            }
        
        
        }

5.Now handle Following events
protected void gvModifyProducts_RowEditing(object sender, GridViewEditEventArgs e)
        {
            try
            {
                gvModifyProducts.EditIndex = e.NewEditIndex;
                BindProductDetails(); 
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        protected void gvModifyProducts_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            try
            {
                BindProductDetails();
                gvModifyProducts.PageIndex = e.NewPageIndex;
                gvModifyProducts.DataBind();
           }
            catch (Exception ex)
            {
                throw ex;
            }
         }

        protected void gvModifyProducts_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
        {
          gvModifyProducts.EditIndex = -1;
            BindProductDetails();

        }
        protected void gvModifyProducts_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            try
            {
                int intID = int.Parse(gvModifyProducts.Rows[e.RowIndex].Cells[0].Text);
                TextBox txtName = (TextBox)gvModifyProducts.Rows[e.RowIndex].Cells[1].FindControl("txtName");
                TextBox txtDesc = (TextBox)gvModifyProducts.Rows[e.RowIndex].Cells[2].FindControl("txtDesc");
                TextBox txtPrice = (TextBox)gvModifyProducts.Rows[e.RowIndex].Cells[3].FindControl("txtPrice");
                TextBox txtQuant = (TextBox)gvModifyProducts.Rows[e.RowIndex].Cells[4].FindControl("txtQuantity");
//This Code is used to handle Validations like Required field
                if (txtName.Text.Trim() == "")
                {
                    txtName.Focus();

                }
               else if (txtDesc.Text.Trim() == "")
                    txtDesc.Focus();
               else if (txtPrice.Text.Trim()=="")txtPrice.Focus();
                else if (txtQuant.Text.Trim()=="")
               txtQuant.Focus();
                else
                {
              var data =
                    (from c in context.PRODUCTS
                     where c.Product_ID == intID
                     select c).First();

                    data.Product_Name = txtName.Text;
                    data.Product_Desc = txtDesc.Text;
                    data.Product_Price = decimal.Parse(txtPrice.Text);
                    data.Quantity = int.Parse(txtQuant.Text);
                    context.SaveChanges();

                    lblMsg.Visible = true;
                    lblMsg.Text = "Product Updated Successfully!!!";
                    BindProductDetails();
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        protected void gvModifyProducts_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            try
            {
                int intID = int.Parse(gvModifyProducts.Rows[e.RowIndex].Cells[0].Text);
                PRODUCT p = new PRODUCT();
                p = (from c in context.PRODUCTS
                     where c.Product_ID == intID
                     select c).First();
                context.PRODUCTS.DeleteObject(p);
                
                context.SaveChanges();

                lblMsg.Visible = true;
                lblMsg.Text = "Product  deleted Successfully!!!";
                BindProductDetails();

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

CRUD
READ,UPDATE and DELETE

Hope this article helped you, do write your feedback and comments.
Happy Coding ☺ ☺ ☺
You Can DOWNLOAD Code here
Please write your valuable comments if you liked this.☺