Category Archives: ASP.Net

Create Numerical TextBox in ASP.Net using Javascript

How to Create Numerical TextBox in ASP.Net using JavaScript . TextBox allow only 0-9 Digit in ASP.Net.

Create alphanumerical TextBox in ASP.Net using Javascript

Create alphanumerical TextBox in ASP.Net using Javascript. TextBox allow to enter only a-z and 0-9 digit using javascript in asp.net.

Create watermark text for TextBox in ASP.Net using Javascript

How to make a watermark text for TextBox in ASP.Net using Javascript.how to create a watermark textbox in asp.net using javascript.

How to use AJAX in ASP.Net 2008

How to use AJAX control in asp.net c#. Use Update Panel and script manager in ajax in asp.net web application.

How to send a formated mail in ASP.Net

Send HTML Formated e-mail in ASP.Net

Send email with ASP.Net is easy task,
If you want to send email with HTML format, you must write this line in code : message.IsBodyHtml = true;

The code for simple send email is belows :

<%@ Import Namespace=”System.Net.Mail” %>

protected void Page_Load(object sender, EventArgs e)
{
//create the email message
MailMessage email = new MailMessage();
//set the from addresses
email.From = new MailAddress(“meeraacademy@hotmail.com”);

//set the to Address
email.To.Add(“meeraacademy@hotmail.com”);

read more

Send E-mail in ASP.Net C# and VB.Net

Send email in ASP.Net

Send E-mail in ASP.Net 2.0 is easy task…

First Add Namespace System.Net.Mail to send email.

Send email using C#

<%@ Import Namespace=”System.Net.Mail” %>

protected void Page_Load(object sender, EventArgs e)
{
//create the email message
MailMessage email = new MailMessage();
//set the from addresses
email.From = new MailAddress(“meeraacademy@hotmail.com”);

//set the to Address
email.To.Add(“meeraacademy@hotmail.com”);

//set the email subject and body , message
email.Subject = “Subject of Email – MeeraAcademyl”;
email.Body = “This is the Body of Email / Message of Email.”;

read more

Cookies in ASP.Net

Cookies in ASP.Net C#

Cookies are small Pieces if text file, Stored on the Client Computer. There are many name of cookies like HTTP Cookie, Web Cookie, Browser Cookie, Session Cookie. Create Cookies
Response.Cookies["MeeraAcademy"].Value = txtvalue.Text;
Response.Cookies["MeeraAcademy"].Expires = DateTime.Now.AddYears(30);
Retrieve Cookies on web page

if (Request.Cookies["MeeraAcademy"] == null)
        {
            TextBox1.Text = “No cookie found”;
        }
        else
        {
            TextBox1.Text = Request.Cookies["MeeraAcademy"].Value;
        } 

Send E-mail using ASP.Net

Send e-mail using c# in ASP.Net.


first Import the below namespace in your web application.

  • using System.Net.Mail; 

Code for Send email using ASP.Net

MailMessage message = new MailMessage();
MailAddress fromAddress = new MailAddress(“meera@academy.com”, YourName);message.From = fromAddress;

message.To.Add(“info@academy.com”);  message.Subject = “Meera Academy – Information”;
message.IsBodyHtml = false;
message.Body = “Your Message”;

SmtpClient sc = new SmtpClient();

sc.Host = “smtp.gmail.com”;                           
sc.Port = 587;
sc.Credentials = new System.Net.NetworkCredential(“demo@gmail.com”, “gmailpassword”);

read more

How to Detect Refresh or Postback in ASP.NET

We are always checking Ispostback value. IsPostback will always have the value which was set previously. So for instance, if the page was posted back before refresh, then the value will be true and if the page is not posted back before refresh, then the value will be false.

protected void Page_Load(object sender, EventArgs e)   

{       

if (!IsPostBack)       

{           

Session["PostID"] = “1001″;           

ViewState["PostID"] = Session["PostID"].ToString();           

Response.Write(“First Load”);       

}       

else       

{           

if (ViewState["PostID"].ToString() == Session["PostID"].ToString())           

{               

Session["PostID"] = (Convert.ToInt16(Session["PostID"]) + 1).ToString();

read more

Page refresh automatic in ASP.Net

Add meta tag in your Head portion and your page will automatically refreshed with 3 second interval.
       


<html xmlns=”http://www.w3.org/1999/xhtml” >
<head runat=”server”>
<title>Meera Academy</title>
<meta http-equiv=”refresh” content=”3 url=http://meeraacademy.com”>
</head>
<body>
<form id=”form1″ runat=”server”>
<div></div>
</form>
</body>
</html>

<meta http-equiv=”refresh” content=”3 url=http://meeraacademy.com”>

read more

MasterPage in ASP.Net

MasterPage in ASP.Net

  • MasterPage is a very useful concept of ASP.Net.
  • A single master page defines the look and feel and standard behavior  for all of the pages in your .Net application. 
  • Start to Create a MastePage in ASP.Net 
  • First, Add new masterpage in your web application from add new item tab. 
  • give the name of masterpage which you want. and then click add button to create new masterpage in your web application.
  • After doing this, you will have a below screen. 
  • which describe the HTML code of MastePage.

read more

Read XML file and Bind to DataGrid in ASP.Net.

Bind XML file to DataGrid

C# .Net

    DataSet DS = new DataSet();
    DS.ReadXml(Server.MapPath("meeraacademy.xml"));
    DataGrid1.DataSource = DS.Tables[0].DefaultView;
    DataGrid1.DataBind();


Create a meeraacademy.xml file.

"1">    
      Meera
      Vasani 
      Modasa

  
Student >
  <
Student id="2">    
      Rahul
      Patel
      Bombay
 
Student >

 

  • Vb.Net

    Dim Ds as New DataSet
    DS.ReadXML(Mappath("meeraacademy.xml"))
    DataGrid1.DataSource=DS
    DataGrid1.DataBind()

    read more