1.What is the main difference between an ASP.NET Web application and a traditional Windows application.
ASP.NET Web applications runs under common language runtime using managed code where as Unmanaged Windows application runs under Windows using unmanaged code.
2.What are the two main parts of the .NET Framework?
The two main parts of the .NET Framework are
1.The common language runtime (CLR).
2.The .NET Framework class library.
3.When can’t you use ASP.NET to create a Web application?
When you are developing for non–Microsoft Windows Web servers, such as Linux/Apache.
4.List the four major differences between Web and Windows applications.
•Web forms cannot use the standard Windows controls. Instead, they use server controls, HTML controls, user controls, or custom controls created specially for Web forms.
•Web applications are displayed in a browser. Windows applications display their own windows and have more control over how those windows are displayed.
•Web forms are instantiated on the server, sent to the browser, and destroyed immediately. Windows forms are instantiated, exist for as long as needed, and are destroyed.
•Web applications run on a server and are displayed remotely on clients. Windows applications run on the same machine they are displayed on.
5.Describe the life cycle of a Web application: When are Web forms instantiated and how long do they exist?
A Web application starts with the first request for a resource within the application’s boundaries. Web forms are instantiated when they are requested. They are processed by the server and are abandoned immediately after the server sends its response to the client. A Web application ends after all client sessions end.
6.How do you preserve persistent data, such as simple variables, in a Web application?
You can preserve data in state variables, such as ApplicationState, SessionState, or ViewState.
7.How does the .NET Framework organize its classes?
The .NET Framework uses namespaces to organize its classes.
8.In Visual Basic .NET, what is the difference between a class module and a code module?
Class modules are instantiated at run time to create objects that provide separate storage for variables and properties in each instance. Code modules do not have instances, so any module-level variables they use are shared among calls to the module’s procedures.
9.In Visual C#, how do you declare a method to make it available without having to first instantiate an object from the class?
To create a method that can be called without instantiating an object, declare that method as static.
10.How do you call a member of a base class from within a derived class?
To refer to a member of a base class in Visual Basic .NET, use the MyBase keyword. To refer to a member of a base class in Visual C#, use the base keyword.
11.Where would you save the following data items so that they persist between requests to a Web form?
•A control created at run time
•An object that provides services to all users
•User preferences
•Save controls created at run time in the Page object’s ViewState.
•Save objects that provide services to all users in the Application state.
•Save user preferences in SessionState.
12.What is the main difference between the Button server control and the Button HTML control?
When clicked, the Button server control triggers an ASP.NET Click event procedure on the server. The Button HTML control triggers the event procedure indicated in the button’s onclick attribute, which runs on the client.
13.How do you get several RadioButton controls to interoperate on a Web form so that only one of the RadioButton controls can have a value of True/true at any given time?
Set the GroupName property of each RadioButton to the same name.
14.Why does ASP.NET perform validation on both the client and the server?
Client-side validation helps avoid round-trips to the server. Validating on the client ensures that the data is valid before it is submitted, in most cases. However, because validation might be turned off (or maliciously hacked) on the client, data must be revalidated on the server side. This provides full assurance that the data is valid while avoiding as many round-trips as possible.
15.What types of validation would you use to verify that a user entered a valid customer number?
You would use a RequiredFieldValidator and a RegularExpressionValidator. If you have access to a list of expected customer numbers, you could replace the RegularExpressionValidator with a CustomValidator that checked the list.
16.Explain the difference between handling transactions at the data set level and at the database level.
Data sets provide implicit transactions, because changes to the data set aren’t made permanent in the database until you call the Update method. To handle transactions in a data set, process the Update method and check for errors. If errors occur during an update, none of the changes from the data set is made in the database. You can try to correct the error and resubmit the update, or you can roll back the changes to the data set using the RejectChanges method.
Databases provide explicit transactions through the Transaction object. You create a Transaction object from a database connection and then assign that Transaction object to the commands you want to include in the transaction through the command object’s Transaction property. As you perform the commands on the database, you check for errors. If errors occur, you can either try to correct them and resubmit the command, or you can restore the state of the database using the Transaction object’s RollBack method. If no errors occur, you can make the changes permanent by calling the transaction object’s Commit method.
17.Explain why exception handling is important to a completed application.
When an unhandled exception occurs in an application, the application stops—the user can’t proceed, and any work he or she did immediately prior to the exception is lost. Exception handling provides a way to intercept and correct unusual occurrences that would otherwise cause these problems.
18.List two different exception-handling approaches in ASP.NET Web applications.
Exceptions can be handled in exception-handling blocks using the Try, Catch, and Finally keywords in Visual Basic .NET or the try, catch, and finally keywords in Visual C#. They can also be handled using Error event procedures at the Global, Application, or Page levels using the Server object’s GetLastError and ClearError methods.
19.Describe the purpose of error pages and why they are needed.
Because Web applications run over the Internet, some exceptions occur outside the scope of the application. This means that your application can’t respond directly to these exceptions. These types of exceptions are identified by HTTP response codes, which IIS can respond to by displaying custom error pages listed in your application’s Web.config file.
20.Explain why tracing helps with exception handling.
Tracing allows you to record unusual events while your application is running, without users being aware of it. If an unanticipated exception occurs, your application can write a message to the trace log, which helps you diagnose problems during testing and after deployment.
21.How do you call a stored procedure?
Create a command object, set the object’s CommandText property to the name of the stored procedure, and set the CommandType property to StoredProcedure. To execute the stored procedure, use the command object’s ExecuteNonQuery, ExcecuteScalar, ExecuteReader, or ExecutelXmlReader method. For example, the following code calls the Ten Most Expensive
Products stored procedure on the Northwind Traders database:
// Create a connection for NorthWind Trader's database.
SqlConnection connNWind = new SqlConnection("integrated security=SSPI;" +
"data source=(local);initial catalog=Northwind");
// Create a command object to execute.
SqlCommand cmdTopTen = new SqlCommand(connNWind);
cmdTopTen.CommandText = "Ten Most Expensive Products";
// Set the command properties.
cmdTopTen.CommandType = CommandType.StoredProcedure;
// Create a data reader object to get the results.
SqlDataReader drdTopTen;
// Open the connection.
connNWind.Open();
// Excecute the stored procedure.
drdTopTen = cmdTopTen.ExecuteReader();
ASP.NET Web applications runs under common language runtime using managed code where as Unmanaged Windows application runs under Windows using unmanaged code.
2.What are the two main parts of the .NET Framework?
The two main parts of the .NET Framework are
1.The common language runtime (CLR).
2.The .NET Framework class library.
3.When can’t you use ASP.NET to create a Web application?
When you are developing for non–Microsoft Windows Web servers, such as Linux/Apache.
4.List the four major differences between Web and Windows applications.
•Web forms cannot use the standard Windows controls. Instead, they use server controls, HTML controls, user controls, or custom controls created specially for Web forms.
•Web applications are displayed in a browser. Windows applications display their own windows and have more control over how those windows are displayed.
•Web forms are instantiated on the server, sent to the browser, and destroyed immediately. Windows forms are instantiated, exist for as long as needed, and are destroyed.
•Web applications run on a server and are displayed remotely on clients. Windows applications run on the same machine they are displayed on.
5.Describe the life cycle of a Web application: When are Web forms instantiated and how long do they exist?
A Web application starts with the first request for a resource within the application’s boundaries. Web forms are instantiated when they are requested. They are processed by the server and are abandoned immediately after the server sends its response to the client. A Web application ends after all client sessions end.
6.How do you preserve persistent data, such as simple variables, in a Web application?
You can preserve data in state variables, such as ApplicationState, SessionState, or ViewState.
7.How does the .NET Framework organize its classes?
The .NET Framework uses namespaces to organize its classes.
8.In Visual Basic .NET, what is the difference between a class module and a code module?
Class modules are instantiated at run time to create objects that provide separate storage for variables and properties in each instance. Code modules do not have instances, so any module-level variables they use are shared among calls to the module’s procedures.
9.In Visual C#, how do you declare a method to make it available without having to first instantiate an object from the class?
To create a method that can be called without instantiating an object, declare that method as static.
10.How do you call a member of a base class from within a derived class?
To refer to a member of a base class in Visual Basic .NET, use the MyBase keyword. To refer to a member of a base class in Visual C#, use the base keyword.
11.Where would you save the following data items so that they persist between requests to a Web form?
•A control created at run time
•An object that provides services to all users
•User preferences
•Save controls created at run time in the Page object’s ViewState.
•Save objects that provide services to all users in the Application state.
•Save user preferences in SessionState.
12.What is the main difference between the Button server control and the Button HTML control?
When clicked, the Button server control triggers an ASP.NET Click event procedure on the server. The Button HTML control triggers the event procedure indicated in the button’s onclick attribute, which runs on the client.
13.How do you get several RadioButton controls to interoperate on a Web form so that only one of the RadioButton controls can have a value of True/true at any given time?
Set the GroupName property of each RadioButton to the same name.
14.Why does ASP.NET perform validation on both the client and the server?
Client-side validation helps avoid round-trips to the server. Validating on the client ensures that the data is valid before it is submitted, in most cases. However, because validation might be turned off (or maliciously hacked) on the client, data must be revalidated on the server side. This provides full assurance that the data is valid while avoiding as many round-trips as possible.
15.What types of validation would you use to verify that a user entered a valid customer number?
You would use a RequiredFieldValidator and a RegularExpressionValidator. If you have access to a list of expected customer numbers, you could replace the RegularExpressionValidator with a CustomValidator that checked the list.
16.Explain the difference between handling transactions at the data set level and at the database level.
Data sets provide implicit transactions, because changes to the data set aren’t made permanent in the database until you call the Update method. To handle transactions in a data set, process the Update method and check for errors. If errors occur during an update, none of the changes from the data set is made in the database. You can try to correct the error and resubmit the update, or you can roll back the changes to the data set using the RejectChanges method.
Databases provide explicit transactions through the Transaction object. You create a Transaction object from a database connection and then assign that Transaction object to the commands you want to include in the transaction through the command object’s Transaction property. As you perform the commands on the database, you check for errors. If errors occur, you can either try to correct them and resubmit the command, or you can restore the state of the database using the Transaction object’s RollBack method. If no errors occur, you can make the changes permanent by calling the transaction object’s Commit method.
17.Explain why exception handling is important to a completed application.
When an unhandled exception occurs in an application, the application stops—the user can’t proceed, and any work he or she did immediately prior to the exception is lost. Exception handling provides a way to intercept and correct unusual occurrences that would otherwise cause these problems.
18.List two different exception-handling approaches in ASP.NET Web applications.
Exceptions can be handled in exception-handling blocks using the Try, Catch, and Finally keywords in Visual Basic .NET or the try, catch, and finally keywords in Visual C#. They can also be handled using Error event procedures at the Global, Application, or Page levels using the Server object’s GetLastError and ClearError methods.
19.Describe the purpose of error pages and why they are needed.
Because Web applications run over the Internet, some exceptions occur outside the scope of the application. This means that your application can’t respond directly to these exceptions. These types of exceptions are identified by HTTP response codes, which IIS can respond to by displaying custom error pages listed in your application’s Web.config file.
20.Explain why tracing helps with exception handling.
Tracing allows you to record unusual events while your application is running, without users being aware of it. If an unanticipated exception occurs, your application can write a message to the trace log, which helps you diagnose problems during testing and after deployment.
21.How do you call a stored procedure?
Create a command object, set the object’s CommandText property to the name of the stored procedure, and set the CommandType property to StoredProcedure. To execute the stored procedure, use the command object’s ExecuteNonQuery, ExcecuteScalar, ExecuteReader, or ExecutelXmlReader method. For example, the following code calls the Ten Most Expensive
Products stored procedure on the Northwind Traders database:
// Create a connection for NorthWind Trader's database.
SqlConnection connNWind = new SqlConnection("integrated security=SSPI;" +
"data source=(local);initial catalog=Northwind");
// Create a command object to execute.
SqlCommand cmdTopTen = new SqlCommand(connNWind);
cmdTopTen.CommandText = "Ten Most Expensive Products";
// Set the command properties.
cmdTopTen.CommandType = CommandType.StoredProcedure;
// Create a data reader object to get the results.
SqlDataReader drdTopTen;
// Open the connection.
connNWind.Open();
// Excecute the stored procedure.
No comments:
Post a Comment