Friday, May 29, 2009
Sending Email Using ASP.NET
I posted this sample send email using ASP.NET
In the below the from,to, bcc, cc are the variables that you have to get values from the corresponding text box and assign it, to send mail.
string body = "Name:" + Name + "
" + "Phone Number:" + PhoneNumber +
/";
MailMessage mMailMessage = new MailMessage();
mMailMessage.From = new MailAddress(from);
mMailMessage.To.Add(new MailAddress(to));
mMailMessage.Body.Insert(1, ClientPhoneNumber);
if ((bcc != null) && (bcc != string.Empty))
{
mMailMessage.Bcc.Add(new MailAddress(bcc));
}
if ((cc != null) && (cc != string.Empty))
{
mMailMessage.CC.Add(new MailAddress(cc));
}
mMailMessage.Subject = subject;
mMailMessage.Body = body;
mMailMessage.IsBodyHtml = true;
mMailMessage.Priority = MailPriority.High;
SmtpClient mSmtpClient = new SmtpClient();
mSmtpClient.EnableSsl = false;
try
{
mSmtpClient.Send(mMailMessage);
lblException1.ForeColor = System.Drawing.Color.Green;
lblException1.Text = "";
lblException1.Text = "Your inquiry has been sent. Thank you!";
}
catch (Exception ex)
{
lblException1.Text = "";
lblException1.Text = Convert.ToString(ex.InnerException);
lblException1.ForeColor = System.Drawing.Color.Red;
lblException1.Text = ex.Message;
}
Enjoy !
Friday, May 22, 2009
Ajax Videos
How Do I: Use an ASP.NET AJAX ScriptManagerProxy
How Do I: Use the ASP.NET AJAX UpdateProgressControl
How Do I: Add ASP.NET AJAX Features to an Existing Web Application?
The source of this videos is from www.youtube.com
ASP.NET AJAX - PageRequestManager and UpdatePanels
Part I
Part II
Part III
Part IV
The source of this Videos from www.youtube.com
Wednesday, May 13, 2009
Upload the image and store it in SQL Server
In the HTML Design
Put the Upload control when and some requred text box for your need to store the required value in the database. Here i have the one text box with name TextBox1 for the name of the image, and i get the max value of the id from the database and increment it by one and pass it as a parameter to the currently inserting value.
VB code for upload the image in SQL
Dim conn As New SqlConnection("server=servername;database=databasename;Trusted_Connection=yes")
Dim Cmd As SqlCommand
stream = FileUpload1.PostedFile.InputStream
Dim uploadedFile(stream.Length) As Byte
namePosition = FileUpload1.PostedFile.FileName.LastIndexOf("\") + 1
fileName = FileUpload1.PostedFile.FileName.Substring(namePosition)
fileType = FileUpload1.PostedFile.ContentType
conn.Open()
//To get the max value of the mytable1
Dim cmd1 As New SqlCommand("select max(id) from Table1", conn)
Dim drd As SqlDataReader = cmd1.ExecuteReader()
Dim strint As String
While drd.Read()
strint = drd(0).ToString
End While
Dim intId As Integer = CType(strint, Integer)
intId = intId + 1
drd.Close()
// Insert the the Image in sql database with image type
Dim command As SqlCommand = New SqlCommand("INSERT INTO mytable1(id,pname,productimage,type1) Values(@id1,@PName1,@PImage1,@imagetype)", conn)
command.Parameters.Add("@id1", SqlDbType.Int, 18).Value = intId
command.Parameters.Add _
("@PName1", _
SqlDbType.NVarChar, 10).Value = TextBox1.Text
command.Parameters.Add _
("@ProductImage1", _
SqlDbType.Image, uploadedFile.Length).Value = uploadedFile
command.Parameters.Add("@imagetype", SqlDbType.NVarChar, 20).Value() = FileUpload1.PostedFile.ContentType
command.ExecuteNonQuery()
conn.Close()
Button1.Text = "Sucessfull"
Friday, May 8, 2009
INTRODUCTION TO ASP.NET AJAX SERVER EXTENDER CONTROL
The server control they included are
1) Script Manager
2) Scrip Manager Proxy
3) Update Panel
4) Update Progress
5) Timer
SCRIPT MANAGER
Script manager must be included before any Ajax Server control or any AJAX client script are include (ie) Partial-page rendering, which enables regions on the page to be independently refreshed without a post back. It manages AJAX Extensions script libraries and script files, partial-page rendering, and client proxy class generation for Web and application services.
SCRIPT MANAGER PROXY
In some situation you have to use more than one Script manager, but per page you can use only one Script Manager at that time you can use Script Manage Proxy.
UPDATE PANEL
By using Asp.Net update panel we can update only that particular region instead of refreshing the entire page. This is referred to as performing a partial-page update.
UPDATE PROGRESS
The UpdateProgress control enables you to provide feedback about the progress of partial-page rendering.
TIMER
The Timer control is to postbacks the page at defined intervals. If we use the Timer control with an UpdatePanel control, we can enable partial-page updates at a defined interval.
Keeo Enjoy!
Basic Of AJAX
AJAX - Asynchronous JavaScript and XML, is used in webdevelopment to enrich the web application. Before ajax the web page has to interact with the server and load the entire page newly each time when the page get loaded. But AJAX interact with the server and load the data in the particular region of the page using javascript. So the page is not get refreshed each time, so user can feel just like the windows application.
Ajax has internet standareds
1) JavaScript
2) XML
3) HTNL
4) CSS
XMLHttpRequest object
XMLHttpRequest is an important part of the AJAX web development technique, and it is used by many websites to implement responsive and dynamic web applications. Ajax uses XMLHttpRequest object to interact with the server by sending request to server and receiving response from the server and update the region, this request and response is take place at the background
ASP.NETAJAX 3.5
In the VS2008 now the AJAX is get included with the .NET Framework3.5, so there is no need to download the separately for ajax. Apart from the Ajax basics control there are several AJAX server extender control is also available you can make use of it for easy programming. To download the Ajax Control Toolkit click here
How to Download Ajax control Toolkit for framework3.5
1) After download the zip file from the above link. Just extract the zip file In a separate folder .
2) Create a separate tab in Toolbox for AJAX Toolkid
3) Right click inside the Tab control choose the browse button then select the path where you extract the Toolkit. Inside that Select SampleWebsite => bi n=> insid that select the AjaxControlToolkit.dll. click ok
Now the Extender control is ready for use. Keep Enjoy !