Sunday, 26 October 2014

How to update Eclipse?

1. Go to Help --> Check for Updates.

How to write an Apex trigger

Want to get a deeper understanding of our simple apex trigger? Look no further!
Here’s a reminder of the code we wrote in the original post:
trigger ForceForecasting on User (before insert) {
for (User userInLoop : Trigger.new) {
userInLoop.ForecastEnabled = true;
}
}
Let’s take a look at the most important line first. I gave this line a deep green background so you’d know it’s critical!
userInLoop.ForecastEnabled = true;
You can take away nothing else from this post, but just know that this is where all the magic happens. If you wanted to auto-populate the “Company” field on every new user instead, you could change this line to:
userInLoop.CompanyName = 'Google, Inc.';
…while leaving every other line of code the same and it would work!
Let’s move on to the next most important lines of code. This is our loop:
for (User userInLoop : Trigger.new) {
...
}
If this code was translated to normal talk, it would say “For every user in our trigger, do everything inside the brackets { }”. Every Salesforce trigger will always have one of these loops.
Finally, let’s talk about the boilerplate code. You can skip this if you want to save brain power.
trigger ForceForecasting on User (before insert) {
    ...
}
Every trigger in Salesforce has this boring code wrapped around it. All it does is “start” and “end” the trigger.
Glossary of Variables Used
trigger – Every trigger must begin with this!
ForceForecasting – this is the name we gave our trigger. We could’ve named it anything we wanted to!
User – This is the name of the standard sObject in Salesforce. Having this in the first line of code tells our trigger to operate on changes to this object. We can use custom objects too… Salesforce is so awesome!!!
before insert – This tells the trigger to fire before the User is inserted/created. We could’ve saidbefore update if we wanted to as well. See a full list of operations here.
userInLoop – this is the variable we created to represent each specific user in the loop as it iterates one by one across all users in Trigger.new. This variable only exists inside the brackets of the loop! We could’ve made it edit any field on the User object by adding another field API name after the period instead. It’s good manners in the programming world to write variables names in camelCase.
Trigger.new – the special Salesforce variable that is a list of every User captured in our trigger. There will always only be one User unless you’re doing a bulk insert… like through Data Loader!

How to write an Apex trigger

Let’s write a trigger that’s both simple and practical!
We’ll write a trigger on the User object – all it will do is check the “Allow Forecasting” checkbox on every newly created user. Salesforce won’t let us modify this permission in a workflow, but the joke’s on them… we can just write a trigger!
trigger ForceForecasting on User (before insert) {
for (User userInLoop : Trigger.new) {
userInLoop.ForecastEnabled = true;
}
}
I added some color to the code to help you focus on what’s important. More importantly though, the colors will show you what you can ignore… save your brain power!
  • Green highlighted lines means it’s important! The deeper the green, the more useful the code. Skim the code without any highlights, that’s just boilerplate code.
  • Blue colored text are Salesforce reserved variables or sObjects. They have useful functionality that I will teach you to master!
  • Purple colored text are variables that we define. We can name them anything we want!
For now, try to guess what each word/line does based on its color.

asp.net interview questions part- 8

An AppDomain can be thought of as a lightweight process. Multiple AppDomains can exist inside a Win32 process. The primary purpose of the AppDomain is to isolate applications from each other, and so it is particularly useful in hosting scenarios such as ASP.NET. An AppDomain can be destroyed by the host without affecting other AppDomains in the process.
Win32 processes provide isolation by having distinct memory address spaces. This is effective, but expensive. The .NET runtime enforces AppDomain isolation by keeping control over the use of memory - all memory in the AppDomain is managed by the .NET runtime, so the runtime can ensure that AppDomains do not access each other’s memory.
One non-obvious use of AppDomains is for unloading types. Currently the only way to unload a .NET type is to destroy the AppDomain it is loaded into. This is particularly useful if you create and destroy types on-the-fly via reflection.
Yes, .NET framework does support one-way messages. To set a void method as one-way operation, set the OneWay property to true on SoapDocumentMethodAttribute or on SoapRpcMethodAttribute attribute. In such cases, the Web service client is intending to just send some notification to the server and not expect any response. The server in such cases returns 202 Accepted HTTP response to the client. And there will be no output message in the WSDL file for such methods. The support for one-way Web service operations was also added in the latest SOAP Toolkit 3.0 release.
Yes, in addition to XDR and XSD schema validation, .NET continues to support the DTD to validate the XML documents. The System.Xml namespace contains a class named XmlValidatingReader that can be used to validate the XML documents.
It is a Text File that contains the combination of the following:
• Text
• HTML tags
• Script Commands

One of ASP.NET’s most useful features is the extensibility of the HTTP pipeline, the path that data takes between client and server. You can use them to extend your ASP.NET applications by adding pre- and post-processing to each HTTP request coming into your application. For example, if you wanted custom authentication facilities for your application, the best technique would be to intercept the request when it comes in and process the request in a custom HTTP module.






Read All Questions :-asp.net interview questions part-(1 to 8)
You have gain more knowledge

Visit Daily 

 best of luck !






asp.net interview questions part- 7

The process in which a Web page sends data back to the same page on the server.
Just call SetNoStore on the HttpCachePolicy object exposed through the Response object’s Cache property, as demonstrated here:




SetNoStore works by returning a Cache-Control: private, no-store header in the HTTP response. In this example, it prevents caching of a Web page that shows the current time.
VSDISCO files are DISCO files that support dynamic discovery of Web services. If you place the following VSDISCO file in a directory on your Web server, for example, it returns   references to all ASMX and DISCO files in the host directory and any subdirectories not noted in elements:
· 
<DYNAMICDISCOVERY
xmlns="urn:schemas-dynamicdiscovery:disco.2000-03-17">





 
ControlToValidate property and Text property.
System.Web.UI.Page
The CLR computes actual permissions at runtime based on code group membership and the calling chain of the code.
Authentication happens first. You verify user’s identity based on credentials. Authorization is making sure the user only gets access to the resources he has credentials for.
A code group is a set of assemblies that share a security context.
Using System.Security.Permissions;
[assembly:FileDialogPermissionAttribute(SecurityAction.RequestMinimum, Unrestricted=true)].
You can request permission to do something and you can demand certain permissions from other apps. You can also refuse permissions so that your app is not inadvertently used to destroy some data.
Code security is the approach of using permissions and permission sets for a given code to run. The admin, for example, can disable running executables off the Internet or restrict access to corporate database to only few applications. Role-based security most of the time involves the code running with the privileges of the current user. This way the code cannot supposedly do more harm than mess up a single user account. There’s no better, or 100% thumbs-up approach, depending on the nature of deployment, both code-based and role-based security could be implemented to an extent.
Displaying a drop-down list requires a template column in the grid. Typically, the ItemTemplate contains a control such as a data-bound Label control to show the current value of a field in the record. You then add a drop-down list to the EditItemTemplate. In Visual Studio, you can add a template column in the Property builder for the grid, and then use standard template editing to remove the default TextBox control from the EditItemTemplate and drag a DropDownList control into it instead. Alternatively, you can add the template column in HTML view. After you have created the template column with the drop-down list in it, there are two tasks. The first is to populate the list. The second is to preselect the appropriate item in the list — for example, if a book’s genre is set to “fiction,” when the drop-down list displays, you often want “fiction” to be preselected.
Using pagination option in DataGrid control. We have to set the number of records for a page, then it takes care of pagination by itself.
Client side validation is done by default. Server side validation is also possible. We can switch off the client side and server side can be done.
We can Validate the controls in an ASP.NET page by using special validation controls that are meant for this. We have Range Validator, Email Validator.
The cursor position is maintained when the page gets refreshed due to the server side validation and the page gets refreshed.
A language should comply with the Common Language Runtime standard to become a .NET language. In .NET, code is compiled to Microsoft Intermediate Language (MSIL for short). This is called as Managed Code. This Managed code is run in .NET environment. So after compilation to this IL the language is not a barrier. A code can call or use a function written in another language.
Sun left the implementation of a specific garbage collector up to the JRE developer, so their performance varies widely, depending on whose JRE you’re using. Microsoft standardized on their garbage collection.
The CLI (Common Language Infrastructure) is the definiton of the fundamentals of the .NET framework - the Common Type System (CTS), metadata, the Virtual Execution Environment (VES) and its use of intermediate language (IL), and the support of multiple programming languages via the Common Language Specification (CLS). The CLI is documented through ECMA

The CLR (Common Language Runtime) is Microsoft’s primary implementation of the CLI. Microsoft also have a shared source implementation known as ROTOR, for educational purposes, as well as the .NET Compact Framework for mobile devices. Non-Microsoft CLI implementations include Mono and DotGNU Portable.NET.

Read All Questions :-asp.net interview questions part-(1 to 8)
You have gain more knowledge

Visit Daily 

 best of luck !

asp.net interview questions part- 6

Distributed Computing Environment/Remote Procedure Calls (DEC/RPC), Microsoft Distributed Component Object Model  (DCOM), Common Object Request Broker Architecture (CORBA), and Java Remote Method Invocation (RMI).
Initialize an instance of AppSettingsReader class. Call the GetValue method of AppSettingsReader class, passing in the name of the property and the type expected. Assign the result to the appropriate variable.
ErrorProvider control is used in Windows Forms application. It is like Validation Control for ASP.NET pages. ErrorProvider control is used to provide validations in Windows forms and display user friendly messages to the user if the validation fails.  E.g. if we went to validate the textBox1 should be empty, then we can validate as below
1). You need to place the errorprovide control on the form

private void textBox1_Validating(object sender,System.ComponentModel.CancelEventArgs e)
{
ValidateName();
}
private bool ValidateName()
{
bool bStatus = true;
if (textBox1.Text == "")
{
errorProvider1.SetError (textBox1,"Please enter your Name");
bStatus = false;
}
else
errorProvider1.SetError (textBox1,"");
return bStatus;
}

it check the textBox1 is empty . If it is empty, then a message Please enter your name is displayed.
The Debug.Write call won’t be compiled when the DEBUGsymbol is not defined (when doing a release build). Trace.Write calls will be compiled. Debug.Write is for information you want only in debug builds, Trace.Write is for when you want it in release build as well.
There are 5 transactions types that can be used with COM+. Whenever an object is registered with COM+ it has to abide either to these 5 transaction types.
Disabled: - There is no transaction. COM+ does not provide transaction support for this component.
Not Supported: - Component does not support transactions. Hence even if the calling component in the hierarchy is transaction enabled this component will not participate in the transaction.
Supported: - Components with transaction type supported will be a part of the transaction if the calling component has an active transaction.
If the calling component is not transaction enabled this component will not start a new transaction.
Required: - Components with this attribute require a transaction i.e. either the calling should have a transaction in place else this component will start a new transaction.
Required New: - Components enabled with this transaction type always require a new transaction. Components with required new transaction type instantiate a new transaction for themselves every time.
The purpose of Canonical XML is to define a standard format for an XML document. Canonical XML is a very strict XML syntax, which lets documents in canonical XML be compared directly.
Using this strict syntax makes it easier to see whether two XML documents are the same. For example, a section of text in one document might read Black & White, whereas the same section of text might read Black & White in another document, and even in another. If you compare those three documents byte by byte, they’ll be different. But if you write them all in canonical XML, which specifies every aspect of the syntax you can use, these three documents would all have the same version of this text (which would be Black & White) and could be compared without problem. This Comparison is especially critical when xml documents are digitally signed. The digital signal may be interpreted in different way and the document may be rejected.
The Microsoft .NET Compact Framework is designed to run on mobile devices such as mobile phones, Personal Digital Assistants (PDAs), and embedded devices. The easiest way to develop and test a Smart Device Application is to use an emulator.
These devices are divided into two main divisions:
1) Those that are directly supported by .NET (Pocket PCs, i-Mode phones, and WAP devices)
2) Those that are not (Palm OS and J2ME-powered devices).
Windows service is a application that runs in the background. It is equivalent to a NT service.
The executable created is not a Windows application, and hence you can’t just click and run it . it needs to be installed as a service, VB.Net has a facility where we can add an installer to our program and then use a utility to install the service. Where as this is not the case with standard exe

The Repeater class is not derived from the WebControl class, like the DataGrid and DataList. Therefore, the Repeater lacks the stylistic properties common to both the DataGrid and DataList. What this boils down to is that if you want to format the data displayed in the Repeater, you must do so in the HTML markup. The Repeater control provides the maximum amount of flexibility over the HTML produced. Whereas the DataGrid wraps the DataSource contents in an HTML < table >, and the DataList wraps the contents in either an HTML < table > or < span > tags (depending on the DataList’s RepeatLayout property), the Repeater adds absolutely no HTML content other than what you explicitly specify in the templates. While using Repeater control, If we wanted to display the employee names in a bold font we’d have to alter the “ItemTemplate” to include an HTML bold tag, Whereas with the DataGrid or DataList, we could have made the text appear in a bold font by setting the control’s ItemStyle-Font-Bold property to True. The Repeater’s lack of stylistic properties can drastically add to the development time metric. For example, imagine that you decide to use the Repeater to display data that needs to be bold, centered, and displayed in a particular font-face with a particular background color. While all this can be specified using a few HTML tags, these tags will quickly clutter the Repeater’s templates. Such clutter makes it much harder to change the look at a later date. Along with its increased development time, the Repeater also lacks any built-in functionality to assist in supporting paging, editing, or editing of data. Due to this lack of feature-support, the Repeater scores poorly on the usability scale.
However, The Repeater’s performance is slightly better than that of the DataList’s, and is more noticeably better than that of the DataGrid’s. Following figure shows the number of requests per second the Repeater could handle versus the DataGrid and DataList


Read All Questions :-asp.net interview questions part-(1 to 8)
You have gain more knowledge

Visit Daily 

 best of luck !

asp.net interview questions part- 5

The system always reads the current value of a volatile object at the point it is requested, even if the previous instruction asked for a value from the same object. Also, the value of the object is written immediately on assignment.
The volatile modifier is usually used for a field that is accessed by multiple threads without using the lock statement to serialize access. Using the volatile modifier ensures that one thread retrieves the most up-to-date value written by another thread.
It is definitely possible to debug other .Net languages code in a C# project. As everyone knows .net can combine code written in several .net languages into one single assembly. Same is true with debugging.
Attach the aspnet_wp.exe process to the DbgClr debugger.
1.   CorDBG – command-line debugger.  To use CorDbg, you must compile the original C# file using the /debug switch.
2.   DbgCLR – graphic debugger.  Visual Studio .NET uses the DbgCLR.
Unlike classes, structs are value types and do not require heap allocation. A variable of a struct type directly contains the data of the struct, whereas a variable of a class type contains a reference to the data. They are derived from System.ValueType class.
Enum->An enum type is a distinct type that declares a set of named constants.They  are strongly typed constants. They are unique types that allow to declare symbolic names to integral values. Enums are value types, which means they contain their own value, can’t inherit or be inherited from and assignment copies the value of one enum to another.
public enum Grade
{
A,
B,
C
}
Value Type : A variable of a value type always contains a value of that type. The assignment to a variable of a value type creates a copy of the assigned value, while the assignment to a variable of a reference type creates a copy of the reference but not of the referenced object.
The value types consist of two main categories:
* Stuct Type
* Enumeration Type

Reference Type :Variables of reference types, referred to as objects, store references to the actual data. This section introduces the following keywords used to declare reference types:
* Class
* Interface
* Delegate
This section also introduces the following built-in reference types:
* object
* string
There are four types of assemblies in .NET:

Static assemblies
These are the .NET PE files that you create at compile time.
Dynamic assemblies
These are PE-formatted, in-memory assemblies that you dynamically create at runtime using the classes in the System.Reflection.Emit namespace.
Private assemblies
These are static assemblies used by a specific application.
Public or shared assemblies These are static assemblies that must have a unique shared name and can be used by any application.
An application uses a private assembly by referring to the assembly using a static path or through an XML-based application configuration file. While the CLR doesn’t enforce versioning policies-checking whether the correct version is used-for private assemblies, it ensures that an application uses the correct shared assemblies with which the application was built. Thus, an application uses a specific shared assembly by referring to the specific shared assembly, and the CLR ensures that the correct version is loaded at runtime.
In .NET, an assembly is the smallest unit to which you can associate a version number

It is the metadata that describes the assemblies.

Read All Questions :-asp.net interview questions part-(1 to 8)
You have gain more knowledge

Visit Daily 

 best of luck !