Posts

Showing posts from 2009

Auto Refresh .aspx page - ASP.NET

Method 1: Response.AddHeader To Refresh Web page After every 5 Seconds You can add following code, Response.AddHeader("Refresh", "5"); Cricket Sites, Stock Exchange sites use similar logic :) Method 2: In body Tag, window.setTimeout The 1000 = 1 Second... < body onload ="window.setTimeout('window.location.reload()',1000);" > Method 3: In Meta Tag Theres also a meta tag that you can define on the head, but not sure wheter it refreshes even if the content has not finished loading or if it starts counting when the head section loaded. Code would be something like that: < meta content ="600" http-equiv ="refresh" > Method 4: Timer Control : Microsoft ASP.NET 2.0 AJAX Extensions server control In following example, the timer interval is set to 10 seconds <%@ Page Language="C#" AutoEventWireup="true" %> <! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN&q

Auto Sequence Number in Grid Control with Paging

we are going to see how to generate sequence number (row number) in DataGrid. To generate sequence number, we will use the DataGridItem’s ItemIndex property. But For example if we are going to second page with Pagesize 3, then sequence number should start from 4. Code snippet for implementing this method is... < asp:DataGrid id ="DataGrid1" runat ="server" PagerStyle-Mode ="NumericPages" PageSize ="10" AutoGenerateColumns ="False" AllowPaging ="True" > < Columns > < asp:templatecolumn headertext ="Row Number" > < itemtemplate > <% # (DataGrid1.PageSize*DataGrid1.CurrentPageIndex)+ Container.ItemIndex+1 %> </ itemtemplate > </ asp:templatecolumn > < asp:boundcolumn runat ="server" Da

Send Email using Gmail SMTP server - ASP.NET

Send Email using Gmail SMTP server-ASP.NET What is an SMTP server? (pronounced as separate letters) Short for S imple M ail T ransfer P rotocol, a protocol for sending e-mail messages between servers. Most e-mail systems that send mail over the Internet use SMTP to send messages from one server to another; the messages can then be retrieved with an e-mail client using either POP or IMAP. In addition, SMTP is generally used to send messages from a mail client to a mail server. This is why you need to specify both the POP or IMAP server and the SMTP server when you configure your e-mail application. Let's see one example in ASP.NET 2.0 (Web Application) In WebMailSend.aspx.cs file You have to import this namespace for MailMessage. using System.Net.Mail; protected void btnSend_Click( object sender, EventArgs e) { try { MailMessage mail = new MailMessage(); mail.IsBodyHtml = true ; mail.To.Add(txtEmail.Text); mail.Subject = txtSubject.Text; mail.

Applying Dynamic Themes to WebPage

Applying Dynamic Themes to Web Page (.aspx) in ASP.NET Themes and Skins. The themes and skins features in ASP.NET 2.0 allow for easy customization of your site's look-and-feel. You can define style information in a common location called a "theme", and apply that style information globally to pages or controls in your site. Like Master Pages, this improves the maintainability of your site and avoid unnecessary duplication of code for shared styles. protected void Page_PreInit( object sender, EventArgs e) { Page.Theme = Session[ "Theme" ] as string ?? "Theme1" ; } protected void Page_Load( object sender, EventArgs e) { } protected void Button1_Click( object sender, EventArgs e) { if (Session[ "Theme" ] != null ) { if (Session[ "Theme" ].ToString() == "Theme1" ) Session[ "Theme" ] = "Theme2" ; else Session[ "Theme" ] = "Theme1&quo

Paged Data Source - Custom Paging

PagedDataSource , is a class that encapsulates the paging related properties for data-bound controls such as DataGrid, GridView, DataList, DetailsView and FormView that allow it to perform paging. And this article is going to combine both DataList control and PagedDataSource class to explain dynamic or custom paging methods for Asp.Net developers. protected void Page_Load( object sender, EventArgs e) { try { if (!IsPostBack) { LoadPhoto(); } } catch (Exception Exc) { HandleException = Exc; } } // LoadPhoto Function private void LoadPhoto() { PagedDataSource objPhotoPage = new PagedDataSource(); objPhotoPage.AllowPaging = true ; SOBLImageGallery _SOBLImageGallery = new SOBLImageGallery(); DataSet dsImageGallery = _SOBLImageGallery.Select6Records( new SOENTImageGallery()); if (dsImageGallery != null && dsImageGallery.Tables.Count > 0 && dsImageGallery.Tables[0].

Abstract Class and An Interface

Abstract Class : The class which cannot be instantiated is known as an Abstract Class . So an object of it cannot be created. Hence it must be inherited. Can't be instantiated. Must be inherited. It may have Concrete Methods & Abstract Methods. An Abstract Class can have only Abstract Method. An Abstract Method must be overridden.     public abstract class AbstractA     {         public abstract string AbstractProperty { get ; set ; }         public abstract void AbstractFunction1();         public virtual void AbstractFunction2()         {             Console .WriteLine( "AbstractA : AbstractFunction2()" );         }         public void AbstractFunction3()         {             Console .WriteLine( "AbstractA : AbstractFunction3()" );         }         public void AbstractFunction4()         {             Console .WriteLine( "AbstractA : AbstractFunction4()" );         }     }     pu