Sunteți pe pagina 1din 5

Abstract Class vs.

Interface

· An abstract class may contain complete or incomplete methods. Interfaces can contain only
the signature of a method but no body. Thus an abstract class can implement methods but an
interface cannot implement methods.
· An abstract class can contain fields, constructors, or destructors and implement properties. An
interface cannot contain fields, constructors, or destructors and it has only the property's
signature but no implementation.
· An abstract class cannot support multiple inheritances, but an interface can support multiple
inheritance. 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.
· Various access modifiers such as abstract, protected, internal, public, virtual, etc. are useful in
abstract Classes but not in interfaces.
· Abstract classes are faster than interfaces.
====================================================

What is the maximum length of a varchar in SQL Server

VARCHAR[(n)]
Null-terminated Unicode character string of length n,
with a maximum of 255 characters. If n is not supplied, then 1 is assumed.
8000 (maximum length)

=======================================

Adding Sub Reports in Crystal reports

To add a sub-report right click on the current report's "Details" section and select "Insert ->
Section"

In the "Insert Section" window select "Details" and click the "Insert" button at the top of the
screen.
This will add a separate "Details" section as shown below.

Click on the "OK" button to finish adding the section. When you are finished you will see a
new section added to the report.

Now, you need to add a sub-report inside the "DetailSection2(Details b)." Right click inside
the Details b section and select "Insert -> Sub-Report" as shown in the screenshot below.
When you select the sub-report option it will create a rectangle where the sub report will be
displayed. Simply place the sub-report rectangle inside the "Details b" section. This will
open an insert Sub-Report window.

=======================================================

Crystal Report Formula Field

To create formula field to display the Quarter of the SalesDate. Right click on the Formula
Fields node in the Field Explorer and select New… from the pop-up menu. Enter Quarter for
the formula name and click the Use Editor button.

This formula will create a variable to hold the running total of any sales that occurred in
quarter 1. Variables have three options for scope: Local, Global, or Shared. Local means
that the variable is used in the specific function and its value is lost once the formula exits.
Global means that the variable will retain its value even after the function exits and can be
used in other formulas in the report. Shared means you can use this variable in other
formulas or even sub reports. By default if you omit the scope of a variable it is Global.

=================================================

Cross Page Posting:


Cross Page posting or cross page postback is used to submit a form on one page (say
default.aspx) and retrieve values of controls of this page on another page (say
Default2.aspx)

There are two ways we can use cross page postsbacks in ASP.NET

1st method
In this i've created a Default.aspx page with two textbox and one button , button click will
post back to Default2.aspx and there we will retrieve and show values of both textboxes

Html source of Default.aspx page is like


<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >


<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
First Name:
<asp:TextBox ID="txtFirstName" runat="server">
</asp:TextBox><br /><br />
Last Name:
<asp:TextBox ID="txtLastName" runat="server">
</asp:TextBox><br /><br /><br />

<asp:Button ID="btnSubmit" runat="server"


OnClick="btnSubmit_Click"
PostBackUrl="~/Default2.aspx"
Text="Submit to Second Page" /><br />
</div>
</form>
</body>
</html>
Don't forget to set PostBackUrl Property of Button
PostBackUrl="~/Default2.aspx"

Now to retrieve values of textBoxes on Default2.aspx page, write below mentioned code in
Page_Load event of second page (Default2.aspx)
C# code behind
protected void Page_Load(object sender, EventArgs e)
{
//Check whether previous page is cross page post back or not
if (PreviousPage != null && PreviousPage.IsCrossPagePostBack)
{
TextBox txtPbFirstName = (TextBox)PreviousPage.FindControl("txtFirstName");
TextBox txtPbLastName = (TextBox)PreviousPage.FindControl("txtLastName");
Label1.Text = "Welcome " + txtPbFirstName.Text + " " + txtPbLastName.Text;
}
else
{
Response.Redirect("Default.aspx");
}
}

S-ar putea să vă placă și