Aug 10, 2011

How to use Send Email Concepts in Asp.net application

The MailMessage and SMTP are classes defined in the .NET Framework Class Library's System.Web.Mail namespace. It is due to a security change made to asp.net just before it shipped, you need to set SMTPMail's, SMTPServer property to localhost even though localhost is the default. In addition, you must use the IIS configuration applet to enable localhost to relay message through the local SMTP Service.


Example:
        MailMessage message = new MailMessage ();
        message.From = <from@testmail.com>;
        message.To = <to@testmail.com>;
        message.Subject = "Welcome to Asp.net Example";
        message.Body = "Free Subscribe to the Asp.net Example";
        SmtpMail.SmtpServer = "localhost";
        SmtpMail.Send (message);

Aug 7, 2011

How to use Calendar with Literal Controls in Asp.net

(i) .ASPX File Content
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!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>Calendar with Literal Controls Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:Calendar Runat="server" ID="Cal" BorderStyle="Solid" BackColor="White" Width="162px" ForeColor="Black" 
     CellSpacing="1" Height="113px" Font-Size="9pt" Font-Names="Verdana" 
     BorderColor="Black" PrevMonthText="Prev" NextMonthText="Next" ShowGridLines="True"
     TitleFormat="Month" SelectionMode="DayWeekMonth" OnSelectionChanged="Cal_SelectionChanged" />
     <Br>
     <asp:Literal ID="Literal1" Runat="server" />
    </div>
    </form>
</body>
</html>
(ii) .ASPX.CS File Content
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Default2 : System.Web.UI.Page
{   
    
    protected void Cal_SelectionChanged(object sender, EventArgs e)
    {
        try
        {            
            foreach (DateTime date in Cal.SelectedDates)
            {
                Literal1.Text = " Selected Date is  :" + date.ToString("d");
            }
        }
        catch (Exception )
        {
            
            throw;
        }
    }
}
(iii) Output

How to Add Two numbers using TextBox Control in asp.net

(i) .ASPX File Content
<%@ 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>Adding Two Number using TextBox Control Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table cellpadding="0" cellspacing="0" width="300px">
         <tr>
          <td><asp:Label ID="Label1" runat="server" Text="First Number"></asp:Label></td>
          <td><asp:TextBox ID="txtFirstNumber" runat="server"></asp:TextBox></td>
         </tr>
         <tr>
          <td><asp:Label ID="Label2" runat="server" Text="Second Number"></asp:Label></td>
          <td><asp:TextBox ID="txtSecondNumber" runat="server"></asp:TextBox></td>
         </tr>
         <tr>
         <td></td>
         <td><asp:Button ID="btnCalculate" runat="server" Text="Submit" OnClick="btnCalculate_Click" /></td>
         </tr>
         <tr>
          <td><asp:Label ID="Label3" runat="server" Text="Result is"></asp:Label></td>
          <td><asp:TextBox ID="txtResult" runat="server"></asp:TextBox> </td>
         </tr>
        </table>    
    </div>
    </form>
</body>
</html>
(ii) .ASPX.CS File Content
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page 
{
    //Declare variables
    int num1, num2, total = 0;
    protected void btnCalculate_Click(object sender, EventArgs e)
    {
        try
        {
            //Adding two numbers
            num1 = int.Parse(txtFirstNumber.Text.ToString().Trim());
            num2 = int.Parse(txtSecondNumber.Text.ToString().Trim());
            total = num1 + num2;
            txtResult.Text = total.ToString();
        }
        catch (Exception)
        {
            throw;
        }
    }
}
(iii) Output

Jul 30, 2011

Asp.net Mobile Challenges, Configuration, Languages, Network Limitations

In. .Net Mobile is an additional extension to the Asp.net and the .NET Framework.  It is a set of server side form controls to building application for wireless mobile devices. These control give output for different devices by generating WML, HTML, or compact HTML.


What is a WML?
Wireless Markup Language, based on XML, is a markup language intended for devices that implement the Wireless Application Protocol (WAP) specification, such as mobile phones. It provides navigational support, data input, hyperlinks, text and image presentation, and forms, much like HTML (HyperText Markup Language).


What is a HTML?
HTML, which stands for HyperText Markup Language, is the predominant markup language for web pages. HTML elements are the basic building-blocks of web pages.


HTML is written in the form of HTML elements consisting of tags, enclosed in angle brackets (like ), within the web page content. HTML tags normally come in pairs like the first tag in a pair is the start tag, the second tag is the end tag (they are also called opening tags and closing tags). In between these tags web designers can add text, tables, images, etc..


The purpose of a web browser is to read HTML documents and compose them into visual or audible web pages. The browser does not display the HTML tags, but uses the tags to interpret the content of the page.

What is a compact HTML?
C-HTML (short for Compact HyperText Markup Language), also called i-mode-HTML,[1] is a subset of HTML for small information devices, such as smart phones and PDAs etc. C-HTML does not support tables, image maps, multiple fonts and styling of fonts, background colors and images, frames, style sheets, and is limited to a monochromatic display

Asp.net Mobile Challenges:
Varying Configuration
Browser Languages
Wireless Network Limitations
Pagination & Session Management


Varying Configuration
It is support memory -2mb to 64mb and capabilities like sound, color displays.
It's displays area -128x160 to 320x480 pixels


Browser Languages
It is supported languages like compact HTML, HTML, WML, HDML, VoiceXML. 


Wireless Network Limitations
It is limited bandwidth is -9.6kbps to 11mbps and also high latency, intermitten connectivity

Jun 22, 2011

Introduction to .NET Mobile Application

Today, It is many tools available on the market for creating application for mobile phones and portable devices.
The Microsoft introduced mobile technology for creating asp.net mobile application. Window mobile is a compact operating system for mobile devices and including Pocket PCs, Smart phones and Portal Media Centers. We can able to develop mobile based application on the Visual Studio 2003, 2005, 2008 to integrated .NET Compact Framework. It is possible to develop impressive mobile window form based and web based application.
.Net Mobile is a set of server-side forms controls to build application for wireless mobile devices. These controls produce different output for different devices by generating WML, HTML or Compact HTML.


Mobile Web Form Controls
Adapts display based on the device capabilities
It is generates multiple markup languages
It is support common desktop controls

AdRotator, Clendar, Command, CompareValildator, DeviceSpecific, Form, Image, Label, Link, List, ObjectList, Selection List, Panel, rabgeValidator, RequiredFieldValidator, RegularExpressionValidator, StyleSheet, TextBox, TextView, Validation Summary and device specific controls like phoneCall