Tuesday, 28 October 2014

GRID VIEW CONTROLS

Note: -In .NET 1.0 we had data grid view control that was replaced in 2.0 with grid view.
         -Data grid 1.1 control available in 2.0.
         -Grid view is faster in performance.
         -it also had a simplified use age.
         -Dynamic nature.
         -Have new features
*Note: We cannot drag and drop a data grid but we have to go to the code and create.
        Data grid in ASP.NET 2.0 can be created just by writing data grid control creation code in source view
        (because there is no drag and drop provided by default)
        Ex: <asp: Data Grid id=”dg1”runat=”server”/>
Grid view features
       -Most featured rich control.
       -Many built-in layouts for designing &dynamic behavior.
       -Supports sorting of data.
       -Supports Paging of data.
       -Supports Editing/Updating/Deleting of data.
       -Collection based approach is provided.
       -Grid view with auto generates columns true on properties that generate columns dynamically.
          When data source is specified at run time and it is by default is TRUE.
       -we can assign different data objects tables at runtime to provide different results.
       - If auto generate columns is set to false then we need to provide columns on our own.
       -With auto generate columns true we can really provide some4 automated sorting /paging tasks
          also.
       -Grid view when assigned to data source control it automatically generates the code that is
          required to show data. It internally sets automate column is set to false.
       -Enable sorting, enable paging.
       -Grid view with data source controls –providing additionally sorting paging.


Bound Controls
                (i)Data Object
                (ii)Design
                (iii)Bind
Steps to create data Grid
(i)Create a data grid view
(ii)Take a button
(iii)Double click on the design screen to go to the code view.
(iv)Grid view has capability to render itself.
                                                                                     COLUMNS: (FALSE)
- When auto generate columns is set to false we have to explicitly provide the columns information.


-

Using predefined fields of grid views like
<asp: Check Box Field…..> (Not normal check box)
<asp: image Field….> (not normal image).
METHOD-3:
Note: Grid view present data tabular presentation purely in the form of rows and columns.
USING BOUND FIELD
 Process: Create button Keep auto generate columns “False” Drag and drop Grid view Go to source
view Use <column><asp: Bound Field…>to define all columns Inside Grid View write this code
                      <asp: Grid view id=”gridview1” runat=”server”>
(//open column//) <Column>
                      <asp: Bound Field Data Field=”Job_id” Header Text=”job_id”/>
                      <asp: Bound Field Data Field=”job_desc”Header Text=”job_desc”/>
                      <asp: Bound Field Data Field=”min_lvl” Header Text=”Min_lvl”/>
                      <asp: Bound Field Data Field=”Max_lvl” Header Text=”Max_lvl”/>
                      </Column>
//Then give the server connection Code in the” Code view window”//
Ex: Using System. Data.SqlClient.
     (The data connection code)
      {
        Sql.Connection cn=new Sqlconnection ("user id=sa; database=”… “; data source=”server");
        cn. Open ( );
        Dataset ds=new Dataset ( );
        Sql Data Adaptor da=new SqlData Adaptor (“select * from “table name”);
        Data Fill (ds,”tablename”);
        Grid view 1.Data source=ds.table [0];
        Grid view 1.Data Bind ( );
        }
**Note:
-Bound Field is better and also only used to display some static data like Data Object Field.
-If we want to display any ”Check Box” ,”Link Button”, “Button” or others and provide action to it then
  we would prefer to use template field.
-Template Field has templates that allow user to define own templates or some custom data .it can be used like a bound
field also.
*Note*:
10

-One Template Field means one column, even though there are 100 columns in Template Field.
Ex:
    <asp: Template Field>
    <Header Template>select</Header template>
    <Item Template>
    <asp: Label id=”lbl 1”text=’<%#Eval (“job-id”) %>’runat=”server”></asp: Label>
    </Item Template>
    <Item Template>
    <asp: Listitem>interested</asp: ListiItem>
    <asp: List item>notintrested</asp: Listitem>
    <asp: List item>buy later</asp: List item>
    </asp: Drop Down List>
    <Item Template>
-To create a data Grid view to Update, Edit, Cancel the database tables we have to follow these steps
The Code to write inside the Data grid Source Code is as below:
<asp: GridView ID="GridView1" runat="server" Height="376px" Style="z-index:
100; left: 8px;
position: absolute; top: 128px" Width="592px">
<Columns>
<asp: BoundField DataField="job_id" HeaderText="jobID" ReadOnly="true" />
<asp: BoundField DataField="desc" HeaderText="Description"/>
<asp: BoundField DataField="min" HeaderText="MinLvl"/>
<asp: TemplateField>
<ItemTemplate>
<asp: TextBox ID="txtmaxlvl" Text='<%#Eval ("max_lvl") %>' runat="server">
<EditItemTemplate>
<asp: DropDownList ID="ddlmaxlvl" runat="server">
<asp: ListItem>100</asp: ListItem>
<asp: ListItem>200</asp: ListItem>
<asp: ListItem>300</asp: ListItem>
</asp: DropDownList>
</EditItemTemplate>
</asp: TextBox>
</ItemTemplate>
</asp: TemplateField>
<asp: CommandField ShowEditButton="true" ShowCancelButton="true" />
</Columns>
</asp: TemplateField>
</asp: GridView>


The Code to write in the View Button Click Code is below:
protected void Button1_Click (object sender, EventArgs e)
{
  {
      BindData ();
  {
       void BindData ();
  {
         SqlConnection=new SqlConnection ("User id=sa, database="pubs);
         cn.Open ();
         Dataset ds=new Dataset ();
         SqlData Adaptor Dataset=new SqlDataAdaptor ("Select * from job", cn);
         Data. Fill (ds,"jobs");
         GridView1.DataBindSome=ds.Tables [0];
         GridView1.DataBind ();
     }
     }
     }
   }
}

-Then run and click on View Button we have to get the result else once again check the code and try.
-or type the following aspnet_regiis-I in Visual Studio Command prompt then enter we have to get a message
 like started installing and then again start run the programmed.
-Then select Grid view go to properties then enter select events and then select Row Editing then double click
  on the that and write the code as follows.
   {
       Gridview1.EditIndex=e.New EditIndex
       BindData ();
   }
Select Row Cancelling Edit then double-click and write the following code.
     {
       Gridview1 EditIndex=-1;
       Bind Data ();
     }
Note: ”e” used to indicate the particular content.
Select Row Updating and double click and write this code
 {
    Response. Write (Gridview1.Rows [e.RowIndex].Cells [0].Text;
    Textbox tjobdese, tminlvl;
    DropdownList dlmaxlvl;
    Tjobdesc= (TextBox) Gridview1.Rows [e.RowIndex}.Cells [1].Cells [1].controls [0];
    Tminlvl= (TextBox) Gridview1.Rows {e.RowIndex].Cells [2].Controls [0];
    Dlmaxlvl= (DropdownList) Gridview1.Rows [e.RowIndex].Findcontrol (“ddlmaxlvl”);
    Response. Write(s);
    Response. Write (tjobdesc.text);
    Response. Write (tminlvl.text);
    Response. Write (dlmaxlvl.Selecteditem.Tostring ());
   //We can also write code to Update db.after Updation.
    Gridview1.EditIndex=-1;


    Bind Data ();
Note: To Check the commands.
-to get the data to the dropdown list from another table.
-take Sql Data some and drop then configure data source.
-connection strings then take the tables then check column which we want
-then go to source and then remove drop down list and in DropdownList, Data source ID=”Sql Data
Source1=”Data
TextFill=”qty”.
<asp: Dropdown List Id=”ddlmaxlvl” runat=”server” Datasource Id=”Sql Data Source 1” Data Text Field=”qty”>

Server side Java Script




HTML Controls Class Hierarchy:
System. Object
System.Web.UI.Con
System.Web.UI.Con
System.Web.UI.Con
HTML Container Control
HTML Image
HTML Input Control
HTML Anchor
HTML Button
HTML Form
HTMLGeneric Control
HTML Image Button
HTMLInput Checkbox
HTML Input File
HTML Input Hidden
HTML Input Image
HTMLInputRadioButton
HTML Select
HTML Table
HTML Table Cell
HTML Table Row
HTML Text Area
HTML Input Text


VALIDATORS

(a) Compare field Validator: Is a Control with compare feature.
      Comparing one control with another control.
Properties:
(i) Control to Validate.
(ii) Control to Compare.
(iii) Operator.
(iv) Type.
(v) Error message.
EX:
      To compare two Quantities or to compare any data with another data we use these validators.lets take an
example of comparing two quantities.




Quantity
Text Box1
Confirm Quantity Compare Validator.
                      Text Box2
Enter
<asp: Compare Validator id=Compare Validator Control to validate “text Box2”
Control to Compare “Text Box1”Operator =”Equal” Error Message=”Quantity mismatch”
Type=String Runat=”server”/>
Interview Point: Server side control :-< asp: Text Box id=Text box1 runat=server/>
               “asp:”in the above line is Tag prefix.
               “Text Box “is the Tag name.
Syntax: <tag prefix: tag name<attributes>runat=server/>
(b) Control-Value
    (i) Control to validate.
    (ii) Value t Compare.
    (iii) Type.
    (iv) Operator.
    (v) Error message.
(c) Control-Data type
     (i) Control to validate.
     (ii) Operator data type check.
     (iii) Type.
     (iv) Error Message.




Regular Expression Validator
(Post.Pre name)
Mobile expression: - \d-->digits
                      \d{10}-->digits of 10
                      \d{1,10}-->between 1 to 10
                      \d{5,10}-->ranging 5 numbers only
                      \d{3} -\d{8} (ex: 040-23754526)
                      \ (A-Z){8}->8 alphabetic characters are allowed
                      \ (a-z A-Z){8}-Caps & Small
Note: Custom validator allows users to write the logic for validating data and then takes care of displaying an
error and form submission. Using custom validator we can perform validation either in client or at server (if
needed both places).client side means using javascript.And server side means using C#.NET.
Note:
ASP.NET controls perform by default validations in the client on submission it also perform validation at
server. This is to ensure more accuracy and also to avoid malfunctioning that may occur during submission of
data.
  Custom validator allows user to implement client side validation using java script.
Custom Validator
Client side java script
Server side java script

Client side JavaScript:
      (1) Place the custom validator in the form and set the following properties.
                (i) Control to Validate
                (ii) Error Message
                (iii) Client validate function
       (2) Go to ‘source’ view or ‘html’ view and add script tag to it .inside script tag write “JavaScript” function
with “two parameters” these two parameters specifies the object and the arguments are passed from control
to function or function to control using which we can perform our required validations.
<script language=”JavaScript”>
Function f1(x, y).
x-is object.
Y-argument.
{
};
Ex: function check data(x, y)
   {
     If (y.value>10)
    Y.Is Valid=True;
    else
    Y.Is valid=False;

Introduction

INTRODUCTION
ASP.NET

ASP.NET, the next version of ASP, is a programming framework used to create enterprise-class Web
Applications. These applications are accessible on a global basis leading to effecient information managment.
The advantages ASP.NET offers is more than just the next version of ASP.
Why ASP.NET?
Since 1995, Microsoft has been constantly working to shift it's focus from Windows-based platforms to the
Internet. As a result, Microsoft introduced ASP (Active Server Pages) in November 1996. ASP offered the
efficiency of ISAPI applications along with a new level of simplicity that made it easy to understand and use.
However, ASP script was an interpreted script and consisted unstructured code and was difficult to debug and
maintain. As the web consists of many different technologies, software integration for Web development was
complicated and required to understand many different technologies. Also, as applications grew bigger in size
and became more complex, the number of lines of source code in ASP applications increased dramatically and
was hard to maintain. Therefore, an architecture was needed that would allow development of Web
applications in a structured and consistent way.
The .NET Framework was introduced with a vision to create globally distributed software with Internet
functionality and interoperability. The .NET Framework consists of many class libraries, includes multiple
language support and a common execution platform. It's a very flexible foundation on which many different
types of top class applications can be developed that do different things. Developing Internet applications with
the .NET Framework is very easy. ASP.NET is built into this framework, we can create ASP.NET applications
using any of the built-in languages.
Unlike ASP, ASP.NET uses the Common Language Runtime (CLR) provided by the .NET Framework. This CLR
manages execution of the code we write. ASP.NET code is a compiled CLR code instead of interpreted code
(ASP). CLR also allows objects written in different languages to interact with each other. The CLR makes
developement of Web applications simple.
Advantages Using ASP.NET

ASP.NET drastically reduces the amount of code required to build large applications
ASP.NET makes development simpler and easier to maintain with an event-driven, server-side
programming model
ASP.NET pages are easy to write and maintain because the source code and HTML are together
The source code is executed on the server. The pages have lots of power and flexibility by this
approach
The source code is compiled the first time the page is requested. Execution is fast as the Web Server
compiles the page the first time it is requested. The server saves the compiled version of the page for
use next time the page is requested
The HTML produced by the ASP.NET page is sent back to the browser. The application source code you
write is not sent and is not easily stolen
ASP.NET makes for easy deployment. There is no need to register components because the
configuration information is built-in
4


The Web server continuously monitors the pages, components and applications running on it. If it
noticies memory leaks, infinite loops, other illegal software or activities, it seamlessly kills those
activities and restarts itself
ASP.NET validates information (validation controls) entered by the user without writing a single line of
code
ASP.NET easily works with ADO .NET using data-binding and page formatting features
ASP.NET applications run fater and counters large volumes of users without performance problems
Differences between ASP.NET and Client-Side Technologies
Client-side refers to the browser and the machine running the browser. Server-side on the other hand refers
to a Web server.
Client-Side Scripting
Javascript and VBScript and generally used for Client-side scripting. Client-side scripting executes in the
browser after the page is loaded. Using client-side scripting you can add some cool features to your page.
Both, HTML and the script are together in the same file and the script is download as part of the page which
anyone can view. A client-side script runs only on a browser that supports scripting and specifically the
scripting language that is used. Since the script is in the same file as the HTML and as it executes on the
machine you use, the page may take longer time to download.
Server-Side Scripting

ASP.NET is purely server-side technology. ASP.NET code executes on the server before it is sent to the
browser. The code that is sent back to the browser is pure HTML and not ASP.NET code. Like client-side
scripting, ASP.NET code is similar in a way that it allows you to write your code alongside HTML. Unlike client-
side scripting, ASP.NET code is executed on the server and not in the browser. The script that you write
alongside your HTML is not sent back to the browser and that prevents others from stealing the code you
developed.

Sales force Deployment Tool Eclipse IDE

Sales force Deployment Tool Eclipse IDE
Given below are advantage and limitation of tools which are used in code and configuration changes deployment from Sandbox to Production.
1. Force.com IDE/ Eclipse IDE
The Force.com IDE is a powerful client application for creating, modifying and deploying Force.com applications into production environment. Based on the Eclipse platform, it provides a comfortable environment for programmer’s familiar with integrated development environments, allowing you to code, compile, test, and package and deploy all from within the IDE itself.
The IDE also features an embedded schema explorer same as Sales force Explorer for a live view of your database and metadata components. Using the standard synchronization features of the IDE, you can create a project that enables multiple developers to develop against a shared source code repository.
Following are the advantages and disadvantage of tool.
Advantage:
  1. It provides a comfortable environment for programmers familiar with integrated development environments, allowing you to the code, compile, test, and package and deploy all from within the IDE itself.
  2. It provide the code editor following are features:
    • Syntax highlighting for the Apex key words.
    • Code assist for Apex system classes, user-defined classes, and schema objects.
    • Click-to-line integration with errors and testing views.
    • Unlimited undo and redo.
    • Tabbed views of source code and XML metadata definition on app.
  1. We can validate the selected classes/trigger etc before deployment.
  2. Execute Anonymous view, which allows you to run the anonymous block of Apex on the server. Anonymous blocks help you to the quickly evaluate Apex on the fly, or to write scripts that change dynamically at runtime.
  3. Force.com IDE provides an Apex Test Runner view where you can test your methods to see which the tests are are passing or failing helpful in Test class.
  4. Metadata files are the text-based, they also can be compared using text diff tools, managed in a version control system such as CVS or Subversion, and even deployed from one Salesforce organization to another
  5. The Schema Explorer is the tool for browsing the objects and fields in a Force.com organization. The browser presents the logged-in user’s view of the Force.com database model, including object visibility, permissions, data types, lookup values and other information that is useful in developing applications on the Force.com platform.
  6. Project Synchronization working Online or Offline project.
  7. If deployment fail it will shows the errors with line number.
  8. A version control system allows you to track changes to a set of files over the time.
Disadvantage:
  1. It takes long time for loading and deployments which is initialization step of our project.
  2. We can’t run our visual force page GUI on browser.
  3. Detailed logs are not generated in Integrated Development Environment. For example system log file.
  4. We are not able to update user profiles using eclipse IDE. Like configuration changes not done in this tool.

Monday, 27 October 2014

Analytic Snapshots in Salesforce

An Analytic Snapshot helps us to create report on historical data. 

Analytic Snapshots comprises of three things:
  • A source Report of type Tabular or Summary
  • A Custom Object with fields matching the columns in the source Report
  • An Analytic Snapshot definition, which maps fields and schedules the snapshot runs 
For reference, kindly check the below link

https://help.salesforce.com/apex/HTViewHelpDoc?id=data_about_analytic_snap.htm&language=en_US

Steps to set Analytic Snapshot:

1. Go to Setup --> Administration Setup --> Data Management --> Analytic Snapshot.


2. Click "Analytic Snapshot" button.

3. Select the Running User, Source Report and Target Object.

4. Click "Save & Edit Field Mappings" button. 


5. Map the fields and click "Save" button.


6. Click "Edit" button in Schedule Analytic Snapshot related list.


7. Set the frequency and preferred start time and click "Save" button.


Email notification:


After clicking the link in email:


An analytic snapshot will fail during a scheduled run if:
  • The source report includes more than 100 fields
  • The source report was changed from summary to tabular
  • The selected grouping level for a summary source report is no longer valid
  • The running user does not have access to the source report
  • The running user does not have the “Run Reports” permission
  • The target object has more than 100 custom fields
  • The target object contains validation rules
  • The target object is included in a workflow
  • The target object is a detail object in a master-detail relationship
  • The target object runs an Apex trigger when new records are created on it
  • The running user does not have the “Create” permission on the target object. Note that if the target object's status is In Development, the running user must have the “Customize Applications” permission.