Pages

Ads 468x60px

For New Update Use this Link http://dotnethubs.blogspot.in/ Offer for you

.

Tuesday 19 March 2013

On Page Load How I Can Send Email using Asp.net

On Page Load How I Can Send Email using Asp.net
In my previous Article I explained how to Sending email with GMail's SMTP server in ASP.NET.
This example shows how to Send Email Using Gmail In ASP.NET. If you want to send mail using Gmail account or it's SMTP server in ASP.NET application if you don't have a working smtp server to send mails than sending e-mail with Gmail is best option.

using System.Net.Mail;
After that write the following code in button click
protected void  Page_Load(object sender, EventArgs e)
{
try
{
string from=Request["from"];
string to=Request["to"];
string password=Request["password"]; 
string subject=Request["subject"];
string Body=Request["Body"]; 
MailMessage Msg = new MailMessage();
// Sender e-mail address.
Msg.From = new MailAddress(from);
// Recipient e-mail address.
Msg.To.Add(txtTo.Text);
Msg.Subject = txtSubject.Text;
Msg.Body = txtBody.Text;
// your remote SMTP server IP.
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
// pass the gmail user id and password
smtp.Credentials=new System.Net.NetworkCredential(from,password);
smtp.EnableSsl = true;
smtp.Send(Msg);
Response.Write("send");
// get the message

}
catch (Exception ex)
{
// Response.Write(ex.Message);
}
}
                   
Here we used smtp.Port=587 this is the port number which is used by gmail that’s why we used this port number. In some situations if you get any error regarding security remove smtp.EnableSsl = true;
Example

  In this example normal you can write a url as shown below .only you have to change the eamil id and password .

localhost:2796/emailsending/mailsender.aspx?from=xyz@gmail.com&to=avc@gmail.com&password=11123344&subject=hello&Body=this is a col example



Download sample code attached

how to Sending email with GMail's SMTP server in ASP.NET

how to Sending email with GMail's SMTP server in ASP.NET
Small Introduction:
Sending email is a very common task in any web application. In almost every web application (web site), their will atleast be an occassion to send email in any fashion.
sending email on page load passing values in query string
The SmtpMail class in ASP .NET provides properties and methods for sending messages using the Collaboration Data Objects for Windows we will see, how can we send email from an ASP .NET page.
Description:
now I will explain how to implement mail sending concept with attachment in asp.net. To implement this concept first we need to following reference to our application System.Web.Mail namespace What is System.Web.Mail
The SmtpMail class in ASP .NET provides properties and methods for sending messages using the Collaboration Data Objects for Windows 2000 (CDOSYS) message component In this article, we will see, how can we send email from an ASP .NET page. In a nut shell, today, we will be looking into the following:

. What we need to send Email from an ASP .NET?
. How to send an email from an ASP .NET page?
. What is new in sending email? (SmtpMail.SmtpServer)
. How can we send attachments in an email?

After that design your aspx page like this
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Send Mail using with gmail crendentials in asp.net</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table style=" border:1px solid" align="center">
<tr>
<td colspan="2" align="center">
<b>Send Mail using gmail credentials in asp.net</b>
</td>
</tr>
<tr>
<td>
Gmail Username:
</td>
<td>
<asp:TextBox ID="txtUsername" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Gmail Password:
</td>
<td>
<asp:TextBox ID="txtpwd" runat="server" TextMode="Password"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Subject:
</td>
<td>
<asp:TextBox ID="txtSubject" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
To:
</td>
<td>
<asp:TextBox ID="txtTo" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td valign="top">
Body:
</td>
<td>
<asp:TextBox ID="txtBody" runat="server" TextMode="MultiLine" Columns="30" Rows="10" ></asp:TextBox>
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Button ID="btnSubmit" Text="Send" runat="server" onclick="btnSubmit_Click" />
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
After that add this namcespace in your codebehind
using System.Net.Mail;
After that write the following code in button click
protected void btnSubmit_Click(object sender, EventArgs e)
{
try
{
MailMessage Msg = new MailMessage();
// Sender e-mail address.
Msg.From = new MailAddress(txtUsername.Text);
// Recipient e-mail address.
Msg.To.Add(txtTo.Text);
Msg.Subject = txtSubject.Text;
Msg.Body = txtBody.Text;
// your remote SMTP server IP.
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.Credentials=new System.Net.NetworkCredential(txtUsername.Text,txtpwd.Text);
smtp.EnableSsl = true;
smtp.Send(Msg);
Msg = null;
Page.RegisterStartupScript("UserMsg", "<script>alert('Mail sent thank you...');if(alert){ window.location='SendMail.aspx';}</script>");
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
                   
Here we used smtp.Port=587 this is the port number which is used by gmail that’s why we used this port number. In some situations if you get any error regarding security remove smtp.EnableSsl = true;
Example


Download sample code attached




Saturday 16 March 2013

jquery and javascript


What is jQuery ?

jQuery is a fast and concise JavaScript Library created by John Resig in 2006 with a nice motto: Write less, do more.
jQuery simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development.
jQuery is a JavaScript toolkit designed to simplify various tasks by writing less code. Here is the list of important core features supported by jQuery:
  • DOM manipulation: The jQuery made it easy to select DOM elements, traverse them and modifying their content by using cross-browser open source selector engine called Sizzle.
  • Event handling: The jQuery offers an elegant way to capture a wide variety of events, such as a user clicking on a link, without the need to clutter the HTML code itself with event handlers.
  • AJAX Support: The jQuery helps you a lot to develop a responsive and feature-rich site using AJAX technology.
  • Animations: The jQuery comes with plenty of built-in animation effects which you can use in your websites.
  • Lightweight: The jQuery is very lightweight library - about 19KB in size ( Minified and gzipped ).
  • Cross Browser Support: The jQuery has cross-browser support, and works well in IE 6.0+, FF 2.0+, Safari 3.0+, Chrome and Opera 9.0+
  • Latest Technology: The jQuery supports CSS3 selectors and basic XPath syntax.

Friday 15 March 2013

Install Mongo on CentOS,Fedora, Ubuntu & Debian

Install MongoDB 2.0.4 on RHEL CentOS Fedora Ubuntu & Debian
This howto guide shows how to install MongoDB 2.0.4 on RHEL 6.2/6.1/6/5.8, CentOS 6.2/6.1/6/5.8, Fedora 16/15/14/13/12, Ubuntu 12.04/11.10/11.04/10.10/10.04 and Debian using MongoDB own YUM repositories for RHEL, CentOS and Fedora and apt-get for Ubuntu and Debian.

What is MongoDB?

MongoDB (from "humongous") is an open source scalable, high-performance and schema-free document-oriented NoSQL database system written in C++. MongoDB bridges the gap between key-value stores (which are fast and highly scalable) and traditional RDBMS systems (which provide structured schemas and powerful queries).

MongoDB Features

  1. Document-oriented storage (the simplicity and power of JSON-like data schemas)
  2. Dynamic queries
  3. Full index support, extending to inner-objects and embedded arrays
  4. Query profiling
  5. Fast, in-place updates
  6. Efficient storage of binary data large objects (e.g. photos and videos)
  7. Replication and fail-over support
  8. Auto-sharding for cloud-level scalability
  9. MapReduce for complex aggregation
  10. Commercial Support, Training, and Consulting

Why MongoDB?

  1. Document-oriented
    1. Documents (objects) map nicely to programming language data types
    2. Embedded documents and arrays reduce need for joins
    3. Dynamically-typed (schemaless) for easy schema evolution
    4. No joins and no multi-document transactions for high performance and easy scalability
  2. High performance
    1. No joins and embedding makes reads and writes fast
    2. Indexes including indexing of keys from embedded documents and arrays
    3. Optional streaming writes (no acknowledgements)
  3. High availability
    1. Replicated servers with automatic master failover
  4. Easy scalability
    1. Automatic sharding (auto-partitioning of data across servers)
      1. Reads and writes are distributed over shards
      2. No joins or multi-document transactions make distributed queries easy and fast
    2. Eventually-consistent reads can be distributed over replicated servers
  5. Rich query language
Install MongoDB 2.0.4 on RHEL 6.2/6.1/6/5.8, CentOS 6.2/6.1/6/5.8, Fedora 16-12, Ubuntu 12.04/11.10/11.04/10.10/10.04 and Debian

How to Install MongoDB 2.0.4 RHEL, CentOS and Fedora

Step 1: Adding 10gen MongoDB Repository

Add 10gen Mongodb-repo (yum-installable RPM packages) on RHEL 6.2/6.1/6/5.8, CentOS 6.2/6.1/6/5.8, Fedora 16-12 for x86 and x86_64 platforms.

For all 32-bit RPM-based distros with yum, put this at /etc/yum.repos.d/10gen.repo:
[10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/
redhat/os/i686
gpgcheck=0
For all 64-bit RPM-based distros with yum, put this at /etc/yum.repos.d/10gen.repo:
[10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/
redhat/os/x86_64
gpgcheck=0

Step 2: Installing MongoDB 2.0.4

Installing MongoDB Database Server on RHEL 6.2/6.1/6/5.8, CentOS 6.2/6.1/6/5.8, Fedora 16-12 for x86 and x86_64 platforms using YUM.
yum install mongo-10gen mongo-10gen-server
Note: for users upgrading from older (pre-2/2011) packaging scheme, it may be necessary to uninstall your existing "mongo-stable", "mongo-stable-server", "mongo-unstable", "mongo-unstable-server" packages before installing the latest mongo-10gen, mongo-10gen-server pacakges.

Step 3: Configure MongoDB Database Server

Open and edit /etc/mongod.conf file with VI Editor. Verify and set basic settings, before starting MongoDB Database Server.
vi /etc/mongod.conf
logpath=/var/log/mongo/mongod.log
port=27017
dbpath=/var/lib/mongo

Step 4: Starting MongoDB Database Server

/etc/init.d/mongod start
## OR ##
service mongod start

Step 5: Testing MongoDB Database Server

Testing with MongoDB command line client.
mongo

Step 6: Executing MongoDB Basic Commands

> show dbs
> show collections
> show users
> use &lt;db name&gt;

Step 7: Starting & Stopping MongoDB

Here is a quick reference to the commands that control the execution of the mongod server process:
service mongodb status 
service mongodb stop
service mongodb start
service mongodb restart
## OR ##
/etc/init.d/mongod status
/etc/init.d/mongod stop
/etc/init.d/mongod start
/etc/init.d/mongod restart

Step 8: Opening MongoDB Port on Firewall

Open file /etc/sysconfig/iptables and add the following line at the bottom and restart iptables.
-A INPUT -m state --state NEW -m tcp -p tcp --dport 27017 
-j ACCEPT
/etc/init.d/iptables restart
## OR ##
service iptables restart

Step 9: Testing MongoDB Remote Connection

mongo serverip:port/databasename
## Example ##
mongo 192.168.1.21:27017/ravisaive

How to Install MongoDB 2.0.4 on Ubuntu and Debian

Step 1: Adding 10gen MongoDB source.list

The 10gen package contains the latest mongoDB version, add below lines at the bottom of the file “/etc/apt/sources.list” on Ubuntu 12.04/11.10/11.04/10.10/10.04 and Debian.

For Ubunut, put these below lines to “/etc/apt/sources.list”:
deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart 
dist 10gen
For Debian, put these below lines to “/etc/apt/sources.list”:
deb http://downloads-distro.mongodb.org/repo/debian-sysvinit 
dist 10gen

step 2: Adding GPG Key

10gen package required GPG key, import it:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 
7F0CEB10

step 3: Insalling MongoDB

sudo apt-get update 
sudo apt-get install mongodb-10gen

step 4: Starting MongoDB

sudo status mongodb
sudo stop mongodb
sudo start mongodb
sudo restart mongodb

step 5: Testing MongoDB

To verify it, just connect it with “mongo
mongo
In case you're facing any difficulties while setting up MongoDB Database Server, please share with us via comment.

Enable or Disable a Controls Like Button, Textbox, Checkbox

JavaScript - Enable or Disable a Controls Like Button, Textbox, Checkbox

JavaScript - Enable or Disable a Controls Like Button, Textbox, Checkbox

Categories:  Javascript | Jquery

                  
Introduction

Here I will explain how to enable or disable a button control in JavaScript or Enable/Disable a controls in JavaScript. 

Description:
  
In previous articles I explained JavaScript Enable/Disable button based on text in textboxes,
jQuery Shake image on mouse over, jQuery upload multiple files usingmultiple file upload plugin, jQuery fancy switch on and off effectsexample and many articles relating to JavaScript, jQuery, asp.net. Now I will explain how to enable or disable a button control in JavaScript.
To set controls enable or disable in JavaScript we need to write the code like as shown below

Enable control in JavaScript
document.getElementById('btnButton').disabled = false;
Disable control in JavaScript
document.getElementById('btnButton').disabled = true;
If you want to see it in complete example check this code
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Enable or Disable a control in javascript</title>
<script language="javascript" type="text/javascript">
//function to enable button if two textboxes contains text
function SetButtonStatus() {
var txt = document.getElementById('txtfirst');
//Condition to check whether user enters text in two textboxes or not
if (txt.value.length >= 1)
document.getElementById('btnButton').disabled = false;
else
document.getElementById('btnButton').disabled = true;
}
</script>
</head>
<body>
<div>
<input type="text" id="txtfirst" onkeyup="SetButtonStatus(this,'btnButton')"/>
<input type="button" id="btnButton" value="Button" disabled="disabled" />
</div>
</body>
</html>
Live Demo

For live demo enter text in textbox whenever we enter text button will enable otherwise it’s in disable mode


Enter Text   Button

database normalization with example

jquery in asp.net

First Normal Form (1NF): No repeating elements or groups of elements

Don’t repeat your columns. Avoid this:

OrderId ItemId1 ItemId2
1 100 101
ItemId1, 2, …
should be split out into relational tables.

Second Normal Form (2NF): No partial dependencies on a concatenated key

This is a complex way of saying that if a column isn’t intrinsically related to the entire primary key, then you should break out the primary key into different tables.

Example:
OrderId (PK) ItemId (PK) OrderDate
1 100 2009-01-01
1 101 2009-01-01
The primary key is (OrderId, ItemId).
Consider OrderDate. It is conceptually part of an order. An order always occurs at some time. But is an OrderDate related to an Item? Not really.
You may be saying, “but items are part of an order!”, and you would be right. But that’s not what I’m getting at. OrderDate is independent of the item itself.
Look at another way: in the table above the OrderDate will always be the same for a given OrderId regardless of the value of the ItemId column. This means data duplication, which is denormalization.
Here’s how we correct the problem:
Orders

OrderId (PK) OrderDate
1 2009-01-01
Order_Items

OrderId (PK) ItemId (PK)
1 100
1 101
Here is an excellent line from the article, “All we are trying to establish here is whether a particular order on a particular date relies on a particular item.”

Third Normal Form (3NF): No dependencies on non-key attributes

2NF covers the case of multi-column primary keys. 3NF is meant to cover single column keys. Simply stated, pull out columns that don’t directly relate to the subject of the row (the primary key), and put them in their own table.
Example:
Orders


OrderId (PK) OrderDate CustomerName CustomerCity
1 2009-01-01 John Smith Chicago
Customer information could be the subject of its own table. Pull out customer name and other customer fields into another table, and then put a Customer foreign key into Orders.
Wikipedia has a great quote from Bill Kent: “every non-key attribute ‘must provide a fact about the key, the whole key, and nothing but the key’.”
 

..




New Updates

Related Posts Plugin for WordPress, Blogger...

Related Result