Saturday, June 20, 2015

Forloop and Foreachloop in C#.net

It depends on what you are doing, and what you need. If you are iterating through a collection of items, and do not care about the index values then foreach is more convenient, easier to write and safer: you can't get the number of items wrong. If you need to process every second item in a collection for example, or process them ion the reverse order, then a for loop is the only practical way.

The biggest differences are that a foreach loop processes an instance of each element in a collection in turn, while a for loop can work with any data and is not restricted to collection elements alone. This means that a for loop can modify a collection - which is illegal and will cause an error in a foreach loop.



The for loop executes a statement or a

block of statements repeatedly until a specified expression evaluates to

false.  there is need to specify the loop bounds( minimum or maximum).


int j = 0;


for (int i = 1; i <= 5; i++)
{
j

= j + i ;
}


The foreach statement repeats a group of

embedded statements for each element in an array or an object

collection.you do not need to specify the loop bounds minimum or

maximum.
int j = 0;


int[] tempArr = new int[] { 0, 1, 2, 3, 5, 8,

13 };
foreach (int i in tempArr )
{
j = j + i ;
}


ATTENDANCE MANAGEMENT SYSTEM PROJECT WITH SOURCE CODE

PROJECT SOURCE CODE

You can download source code of this project from given download links

 Attendance Tracker System, Source Code in : PHP , MYSQL , Category: Management System Major project, Cost : Free Download, Code: Open source.
"Attendance Management System Project in PHP with Report" (Source Code / Report / PPT) Totally belong to CodingTalks Team and We always ready to Share our Stuff
Attendance Management System is a complete system for any organization to take attendance of its staff. It is written in PHP and released as an open source project
Online attendance management system for employees project is a web application which is implemented in Php platform. They are modification this project as per
Attendance Management System 1 Project Report On “Attendance Management System”  Attendance Management System 30 8.2. Attendance Status Form




The purpose of Online Attendance Management System Project in Java is to provide attendance for students in both online and offline and finally we can also generate
Student Attendance Management System Project Topics or Ideas for Computer Science Engineering . Projecttopics.info. Home. Computer. Electronics. IT. Java.
Attendance management system project is developed in Vb.Net programming language using sql server database. Download code, Project Report, PPT ,
Introduction. Attendance Management System is software developed for daily student attendance inschools, colleges and institutes. If facilitates to access the attendance
Attendance Management System is an easy way to keep track of attendance for school activities, church groups, and community organizations. About Us; Projects
 Track employee time and attendance, employee time clock software, employee scheduling software and payroll software all in a single package. You can also
Attendance Management Solution Gaytes Attendance Management solution would be one which is able to automate the tabulations of staff time clocking, calculate
Student Attendance Management System, HBTI, Kanpur, 30.07.2007 Teacher Teacher will access the Student Attendance Management System through their user name
Positive approach to absenteeism which applies principles of behavior modification to achieve improved attendance at work. Although it relies on both reward and
Attendance Management System is a complete system for any organization to take attendance of its staff. It is written in PHP and released as an open source project

DownLoad Link:
DropBoxSoftwarehub

Send email in asp.net

 <%this is the client side code for the design and display%>
<asp:Panel ID="Panel1" runat="server" DefaultButton="btnSubmit">
<p>
Please Fill the Following to Send Mail.</p>
<p>
Your name:
<asp:RequiredFieldValidator ID="RequiredFieldValidator11" runat="server" ErrorMessage="*"
ControlToValidate="YourName" ValidationGroup="save" /><br />
<asp:TextBox ID="YourName" runat="server" Width="250px" /><br />
Your email address:
 
 <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="*"
ControlToValidate="YourEmail" ValidationGroup="save" /><br />
<asp:TextBox ID="YourEmail" runat="server" Width="250px" />
<asp:RegularExpressionValidator runat="server" ID="RegularExpressionValidator23"
SetFocusOnError="true" Text="Example: username@gmail.com" ControlToValidate="YourEmail"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" Display="Dynamic"
ValidationGroup="save" /><br />
Subject:
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="*"
ControlToValidate="YourSubject" ValidationGroup="save" /><br />
<asp:TextBox ID="YourSubject" runat="server" Width="400px" /><br />
Your Question:
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="*"
ControlToValidate="Comments" ValidationGroup="save" /><br />
<asp:TextBox ID="Comments" runat="server"
TextMode="MultiLine" Rows="10" Width="400px" />
</p>
<p>
<asp:Button ID="btnSubmit" runat="server" Text="Send"
OnClick="Button1_Click" ValidationGroup="save" />
</p>
</asp:Panel>
<p>
<asp:Label ID="DisplayMessage" runat="server" Visible="false" />
</p>
 
 
protected void SendMail()
{
// Gmail Address from where you send the mail
var fromAddress = "Gmail@gmail.com";
// any address where the email will be sending
var toAddress = YourEmail.Text.ToString();
//Password of your gmail address
const string fromPassword = "Password";
// Passing the values and make a email formate to display
string subject = YourSubject.Text.ToString();
string body = "From: " + YourName.Text + "\n";
body += "Email: " + YourEmail.Text + "\n";
body += "Subject: " + YourSubject.Text + "\n";
body += "Question: \n" + Comments.Text + "\n";
// smtp settings
var smtp = new System.Net.Mail.SmtpClient();
{
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.EnableSsl = true;
smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtp.Credentials = new NetworkCredential(fromAddress, fromPassword);
smtp.Timeout = 20000;
}
// Passing values to smtp object
smtp.Send(fromAddress, toAddress, subject, body);
}

protected void Button1_Click(object sender, EventArgs e)
{
try
{
//here on button click what will done
SendMail();
DisplayMessage.Text = "Your Comments after sending the mail";
DisplayMessage.Visible = true;
YourSubject.Text = "";
YourEmail.Text = "";
YourName.Text = "";
Comments.Text = "";
}
catch (Exception) { }
}

Patient and Friends


AJAX Control Toolkit Control Extender (C#)

The CSASPNETAjaxExtender sample demonstrates how to create an ASP.Net Ajax ExtenderControl, which is a TimePicker to allow the user dragging the minute/hour pointer to select a time of a day on a clock.
Microsoft ASP.Net Ajax Extensions enables you to expand the capabilities of an ASP.Net Web Application in order to create a rich client user experience.
To encapsulate the client behavior for use by ASP.NET page developers, you can use an extender control.  An extender control is a Web server control that inherits the ExtenderControl abstract class in the System.Web.UI namespace.

1.       Creating an Extender Control.
 We can create ExtenderControl by using the template "Asp.Net Ajax Server Control Extender".
 It will present to you a class file, a resource file(Actually, we don't need it in this sample.) and a JS file as default. We can create the extender in class file and create behavior in JS file.
  
2.       Extender control is used for client script functionality extension of an existing web control. It can be applied to specific Web server control types.
 You identify the types of Web server controls to which an extender control  can be applied by using the TargetControlTypeAttribute attribute.

   [TargetControlType(typeof(TextBox))]
   public class TimePicker: ExtenderControl


3.       The following two methods of the ExtenderControl abstract class that you must implement in an extender control.

   protected override IEnumerable<ScriptDescriptor>  GetScriptDescriptors(Control targetControl)
   {
      ScriptControlDescriptor descriptor = new ScriptControlDescriptor ("CSASPNETAjaxExtender.TimePicker", targetControl.ClientID);
      descriptor.AddElementProperty("errorSpan", this.NamingContainer.FindControl
(ErrorPresentControlID).ClientID);
                   
      descriptor.AddProperty("timeType", TimeType);
      descriptor.AddEvent("showing", OnClientShowing);
      yield return descriptor;
   }


   protected override IEnumerable<ScriptReference> GetScriptReferences()
   {
      yield return new ScriptReference(Page.ClientScript.GetWebResourceUrl
(this.GetType(), "CSASPNETAjaxExtender.TimePicker.TimePicker.js"));
   }

4.       Embed Css reference in PreRender phase if you have a css style file to decorate the extender control.
   private void RenderCssReference()
   {
      string cssUrl = Page.ClientScript.GetWebResourceUrl(this.GetType(), "CSASPNETAjaxExtender.TimePicker.TimePicker.css");

      HtmlLink link = new HtmlLink();
      link.Href = cssUrl;
      link.Attributes.Add("type", "text/css");
      link.Attributes.Add("rel", "stylesheet");
      Page.Header.Controls.Add(link);
   }
  
5.       Set all resources(contain images, css file and js file) embedded in this extender control as "Embedded Resource"(property "Build Action").

6.       The control can derive from other server controls if you want to make it inherit a server control than ExtenderControl. In this scenario, it should derive from
   IExtenderControl interface and a server control class. Meanwhile, we have another
   three steps need to do:
   1) Define TargetControl property
   2) Override OnPreRender method. Register the web control as the ExtenerControl in OnPreRender phase.
  
            ScriptManager manager = ScriptManager.GetCurrent(this.Page);
            if (manager == null)
            {
                throw new InvalidOperationException("A ScriptManager is required on the page.");
            }
            manager.RegisterExtenderControl<TimePicker>(this);
   3) Override Render method. Register the script descriptor which has been defined.
  
            ScriptManager.GetCurrent(this.Page).RegisterScriptDescriptors(this);

7.       The rest work is on client-side. Register client NameSpace first.
 Type.registerNamespace("CSASPNETAjaxExtender");

8.       Build client class.
   CSASPNETAjaxExtender.TimePicker = function(element) {
   
   }

   CSASPNETAjaxExtender.TimePicker.prototype = {

   }

9.       Register the class that inherits "Sys.UI.Behavior".
  
 CSASPNETAjaxExtender.TimePicker.registerClass('CSASPNETAjaxExtender.TimePicker', Sys.UI.Behavior);

10.   Call base method in constructor method
CSASPNETAjaxExtender.TimePicker.initializeBase(this, [element]);

11.   Implementing the Initialize and Dispose Methods.
   Build "initialize" and "dispose" method in prototype of the class. The initialize method is called when an instance of the behavior is created. Use this method to set default property values, to create function delegates, and to add delegates as event handlers. The dispose method is called when an instance of the behavior is no longer used on the page and is removed. Use this method to free any resources that are no longer required for the behavior, such as DOM event handlers.
   initialize: function() {
       CSASPNETAjaxExtender.TimePicker.callBaseMethod(this, 'initialize');      

   },

   dispose: function() {       
       CSASPNETAjaxExtender.TimePicker.callBaseMethod(this, 'dispose');
   }

12.   Defining the Property Get and Set Methods.
Each property identified in the ScriptDescriptor object of the extender control's GetScriptDescriptors(Control) method must have corresponding client assessors.  The client property assessors are defined as get_<property name> and set_<property name> methods of the client class prototype.

   get_timeType: function() {
       return this._timeType;
   },

   set_timeType: function(val) {
       if (this._timeType !== val) {
           this._timeType = val;
           this.raisePropertyChanged('timeType');
       }
   },

13.   Defining the Event Handlers for the DOM Element
   1) Defining the handler in constructor function:
        this._element_focusHandler = null;
   2) Associate the handler with the DOM Element event in initailize method:
           this._element_focusHandler = Function.createDelegate(this, this._element_onfocus);
   3) Add the handler in initailize method:
           $addHandler(this.get_element(), 'focus', this._element_focusHandler)
   4) Build callback method about this event:
           _element_onfocus:function(){

           }

14.   Defining the Event Handlers for the behavior
             Each event identified in the ScriptDescriptor object of the extender control's GetScriptDescriptors(Control) method must have corresponding client accessors. The client event accessors are defined as add_<event name> and remove_<event name> methods of the client class prototype.
   The method Raise<event name> is defined to trigger the event. 

    add_showing: function(handler) {
        this.get_events().addHandler("showing", handler);
    },
    remove_showing: function(handler) {

        this.get_events().removeHandler("showing", handler);
    },
    raiseShowing: function(eventArgs) {

        var handler = this.get_events().getHandler('showing');
        if (handler) {
            handler(this, eventArgs);
        }
    },
   
15.   Use this extender control TimePicker in page.
    The usage of the extender control is the same to the custom control.   
         1) Register the assembly in page.
            <%@ Register TagPrefix="CSASPNETAjaxExtender" Assembly="CSASPNETAjaxExtender"
            Namespace="CSASPNETAjaxExtender" %>
         2) Add a ScriptManager control in page, and create TimePicker control to bind on a TextBox.
        
            <asp:TextBox ID="TextBox1" Text="" runat="server"></asp:TextBox>
            <CSASPNETAjaxExtender:TimePicker runat="server" ID="t1" TargetControlID="TextBox1" TimeType="H24" />
3) Then we have built this TimePicker on the page as below. You can drag the minute or hour pointer to locate the time.

Friday, June 19, 2015

USB Bootable

How we make bootable USB

 Bootable Windows 7 USB flash drive :
 For those who don’t have a windows 7 installation disk or either it is damaged, then you can create and use a Bootable USB flash drive to install Windows 7 on your PC. The process of creating a Bootable windows 7 USB flash drive is fairly easy, however you will have to download a copy of windows 7 ISO file.

Instructions to create a Bootable Windows 7 USB Flash Drive 

  • Step 1: Download rufus on your computer and run it .
  • Step 2: Plug in your USB flash drive into your computer .
  • Step 3: From Rufu’s settings, Choose NTFS as the file system.
  • Step 4: Check ” Quick format ” and ” Create extended label and icon files
  • Step 5: Check ” Create a bootable disk using ” and click the drive icon beside it to select the windows 7 ISO file .
  • Step 6: Now click on start to create a bootable window 7 USB flash drive .

After a few minutes your Windows 7 bootable  USB flash drive will be  ready for installation. Reboot your PC and set the bootable flash drive as a first boot priority in the bios settings. Save the bios settings and reboot once again to continue with the windows 7 installation process .
 Note: You have to allow booting from USB devices in your BIOS settings in order to proceed further with the windows 7 installation .


Bootstrap Responsive GridView for Mobile Phone, Tablet in ASP.Net.

How we make Responsive grid view in asp.net using bootstrap.

<asp:GridView ID="GridViewCustomer " CssClass="footable" runat="server" AutoGenerateColumns="false"
    Style="max-width: 500px">
    <Columns>
        <asp:BoundField DataField="Id" HeaderText="Customer Id" />
        <asp:BoundField DataField="name" HeaderText="Customer name" />
        <asp:BoundField DataField="address" HeaderText="Country" />
    </Columns>
</asp:GridView>

Binding the GridView 
The GridViewCustomer is populated using some dummy records using DataTable, you can populate it from database too.
After the GridView is populated with data you will need add the following attributes to each Header Column of GridView depending on its significance in different displays.
1. data-class = “expand” – You need to specify this attribute to the first column so that it shows the expand collapse button which will be used to show or hide the hidden column fields in Mobile Phone or Tablet.
2. data-hide = “phone” – You need to specify this attribute for all the columns that you want to hide in smaller displays like Mobile Phone or Tablet. The below table displays the possible values.
protected void Page_Load(object sender, EventArgs e)
{
    if (!this.IsPostBack)
    {
        DataTable dt = new DataTable();
        dt.Columns.AddRange(new DataColumn[3] { new DataColumn("Id"), new         DataColumn("Name"), new DataColumn("Country") });
        dt.Rows.Add(1, "John Hammond", "United States");
        dt.Rows.Add(2, "Mudassar Khan", "India");
        dt.Rows.Add(3, "Suzanne Mathews", "France");
        dt.Rows.Add(4, "Robert Schidner", "Russia");
        GridView1.DataSource = dt;
        GridView1.DataBind();
        //Attribute to show the Plus Minus Button.
        GridView1.HeaderRow.Cells[0].Attributes["data-class"] = "expand";
        //Attribute to hide column in Phone.
        GridView1.HeaderRow.Cells[2].Attributes["data-hide"] = "phone";
        GridView1.HeaderRow.Cells[3].Attributes["data-hide"] = "phone";
        //Adds THEAD and TBODY to GridView.
        GridView1.HeaderRow.TableSection = TableRowSection.TableHeader;
    }
}

<link href="https://cdnjs.cloudflare.com/ajax/libs/jquery-footable/0.1.0/css/footable.min.css"
    rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-footable/0.1.0/js/footable.min.js"></script>
<script type="text/javascript">
    $(function () {
        $('[id*=GridViewCustomer ]').footable();
    });
</script>

Make Money Online.

How we make money online.
  • There are many ways to make money online.
  • First One is freelancing.here you create your account and make perfect profile.This is great plateform
  • Odesk is an other way.
  • Good   adsense is great thing.

Responsive with asp.net datalist control

I have a problem with responsive using datalist control. But I have resolved this issue set Repeatlayout="Flow"

asp:DataList ID="DataList1" runat="server"  RepeatLayout="Flow">
<ItemTemplate>
<div class="col-sm-4 products">
<div class="news_img">
<asp:Image ID="Image1" runat="server" class="img-responsive center-block" ImageUrl='<%# bind("backgroundimage") %>'/>
</div>
<h2 class="heading1">
<asp:Label ID="lblName" runat="server" Text='<%# bind("Name") %>'></asp:Label></h2>
<p class="product_con">
<asp:Label ID="lblDescription" runat="server" Text='<%# bind("Description") %>'></asp:Label></p>
<div class="btn btn-primary center-block"><a href="#">+ Read More</a></div>
</div>
 
</ItemTemplate>
 
</asp:DataList>

Common Language Runtime in C#

  1.  The Common Language Runtime (CLR) is the programming (Virtual Machine component) that manages the execution of programs written in any language that uses the .NET Framework, for example C#, VB.Net.
  2. The information about the environment, programming language, its version and what class libraries will be used for this code are stored in the form of metadata with the compiler that tells the CLR how to handle this code.
  3. The CLR allows an instance of a class written in one language to call a method of the class written in another language.

Tuesday, June 16, 2015

ASP and ASP.NET

The basic difference between ASP and ASP.NET is that ASP is interpreted; whereas, ASP.NET is compiled. This implies that since ASP uses VBScript; therefore, when an ASP page is executed, it is
interpreted. On the other hand, ASP.NET uses .NET languages, such as C# and VB.NET, which are compiled to Microsoft Intermediate Language (MSIL).

Abstract and Interface

Abstract Class:
-Abstract class provides a set of rules to implement next class
-Rules will be provided through abstract methods
-Abstract method does not contain any definition
-While inheriting abstract class all abstract methods must be override
-If a class contains at least one abstract method then it must be declared as an “Abstract Class”
-Abstract classes cannot be instantiated (i.e. we cannot create objects), but a reference can be created
-Reference depends on child class object’s memory
-Abstract classes are also called as “Partial abstract classes”
-Partial abstract class may contain functions with body and functions without body
-If a class contains all functions without body then it is called as “Fully Abstract Class” (Interface)

Interface:

-If a class contains all abstract methods then that class is known as “Interface”
-Interfaces support like multiple inheritance
-In interface all methods r public abstract by default
-Interfaces r implementable
-Interfaces can be instantiated, but a reference cannot be created

What is the use of DISPOSE method

Dispose method belongs to ‘IDisposable’ interface. We had seen in the previous section how bad
it can be to override the finalize method for writing the cleaning of unmanaged resources. So if
any object wants to release its unmanaged code best is to implement I Disposable and override
the Dispose method of I Disposable interface. Now once your class has exposed the Dispose
method it is the responsibility of the client to call the Dispose method to do the cleanup

Sunday, June 14, 2015

Entity framework

What is the Entity framework?

 The Entity framework is an object-relation mapper, means - it takes the structure of the database and turns it into objects that the .Net framework can understand. Developers use those object to interact with the database instead of interacting with database directly. It’s possible to perform the full set of Create, Read, Update, and Delete (CRUD) operations using the Entity Framework features

 

It has three work flows
  1. Code – first,
  2. Model-first and
  3. database first.


    Their detail will be provided in next Post

Wednesday, June 10, 2015

Download ADT bundle Eclipse Android.

For Dowloading ADT bundles free from Fllowing link.
Link:
http://developer.android.com/sdk/installing/installing-adt.html

Android Store image in SD card.

Store image in Sd card we need permission in Android manifest.
 Add android.permission.WRITE_EXTERNAL_STORAGE permission to you AndroidManifest.xml.

Foreach Loop on Datatable in C#

For Each Loop on Datatable.

DataTable dt = GetTable(); // Get the data table.
foreach (DataRow row in dt.Rows) // Loop over the rows.
{
string value=row["name"].tostring();
}

Foreach loop on String Array in C#.

How we use foreach loop on string array.

string[] Frutes = { "Mango", "Apple", "banana" };

// Loop with the foreach keyword.
foreach (string value in Frutes )
{
Console.WriteLine(value);
}

Read Write in Existing Pdf File in C# using iTextSharp.

How we read and write pdf file data using Itextsharp.Like



public string ReadPdfFile(string fileName)
{
    StringBuilder text = new StringBuilder();

    if (File.Exists(fileName))
    {


        PdfReader pdfReader = new PdfReader(fileName);

        for (int page = 1; page <= pdfReader.NumberOfPages; page++)
        {
            ITextExtractionStrategy strategy = new SimpleTextExtractionStrategy();
            string currentText = PdfTextExtractor.GetTextFromPage(pdfReader, page, strategy);

            currentText = Encoding.UTF8.GetString(ASCIIEncoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.Default.GetBytes(currentText)));
            text.Append(currentText);
        }
        pdfReader.Close();
    }
    return text.ToString();
}


Edit a PDF Document from an existing PDF Document using Itextsharp:

string originalFile = "Original.pdf";
string copyOfOriginal = "CopyFile.pdf";
using (FileStream fs = new FileStream(originalFile, FileMode.Create, FileAccess.Write, FileShare.None))
using (Document doc = new Document(PageSize.LETTER))
using (PdfWriter writer = PdfWriter.GetInstance(doc, fs))
{
    doc.Open();
    doc.Add(new Paragraph("Hi! I'm Original"));
    doc.Close();
}
PdfReader reader = new PdfReader(originalFile);
using (FileStream fs = new FileStream(copyOfOriginal, FileMode.Create, FileAccess.Write, FileShare.None))
// Creating iTextSharp.text.pdf.PdfStamper object to write
// Data from iTextSharp.text.pdf.PdfReader object to FileStream object
using (PdfStamper stamper = new PdfStamper(reader, fs)) { }

Android Grid View

DisPlay Data in GridView 
Display  A to Z in GridView layout.It is very simple. 
<?xml version="1.0" encoding="utf-8"?>
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridView1"
android:numColumns="auto_fit"
android:gravity="center"
android:columnWidth="50dp"
android:stretchMode="columnWidth"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
 
</GridView>
  android.widget.ArrayAdapter;
import android.widget.GridView;
import android.widget.TextView;
import android.widget.Toast;
import android.view.View;
import android.widget.AdapterView.OnItemClickListener;
 
public class GridViewActivity extends Activity {
 
GridView gridView;
 
static final String[] numbers = new String[] {
"A", "B", "C", "D", "E",
"F", "G", "H", "I", "J",
"K", "L", "M", "N", "O",
"P", "Q", "R", "S", "T",
"U", "V", "W", "X", "Y", "Z"};
 
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
 
setContentView(R.layout.main);
 
gridView = (GridView) findViewById(R.id.gridView1);
 
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, numbers);
 
gridView.setAdapter(adapter);
 
gridView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v,
int position, long id) {
Toast.makeText(getApplicationContext(),
((TextView) v).getText(), Toast.LENGTH_SHORT).show();
}
});
 
}
 
}