Introduction: In
this article today I am going to explain how we can use the multiview control
in asp.net.
In the previous article I have explained Explain hidden fields in asp.net with example, Explain Querystring in asp.net with example, Advantages and Disadvantages of Querystring, Explain cookies in asp.net OR Explain cookies with example in asp.net and Pass multiple variables using Querystring in asp.net .
Saturday, December 27, 2014
Saturday, December 6, 2014
Introduction: In
this article I am trying to explain Hidden fields in asp.net with example.
Description:
Hidden field is control in Asp.net or input control. It is
used to store small amount of data. The data is store on the client side. It
store only one value for variable and is saved as string. It is not visible in
browser but can see the stored data by using view source operation of the browser.
Tuesday, December 2, 2014
Introduction:
In this article today I am going to explain how we can pass multiple variables using querystring in asp.net
Description:
In the previous article I have explained Explain Querystring in asp.net with example, Advantages and Disadvantages of Querystring, Explain cookies in asp.net OR Explain cookies with example in asp.net and Get, insert, update and delete the data using one stored procedure in Sql server
Thursday, November 27, 2014
Introduction:
In this article today I am going to explain Advantages and Disadvantages of
Querystring
Description:
Advantages:
1. It is supported by all browsers.
2. Querystring is easy to use.
3. Server resources are not required.
4. Extra afford are not needed to code.
Disadvantages:
Wednesday, November 26, 2014
Introduction:
In this article today I am going to explain Querystring in asp.net with example
Description:
Querystring is a way to passing data from one page to
another page through the URL. Data that is append to end of a page URL. We pass
the information from one page and on another page can retrieve it.
Advantages:
1. It is supported by all browsers.
2. Querystring is easy to use.
3. Server resources are not required.
4. Extra afford are not needed to code.
Disadvantages:
1. All information is visible to user. Therefore, it is
not secure.
2. There is a limit to URL length of 255 characters.
Example:
Wednesday, November 19, 2014
Introduction: Today I am
going to explain how we can Get, Insert, Update and Delete the records using
one store procedure in sql server
Description:
Now I create a store procedure to perform all action:
Create procedure Emp_Tb_IUDS
(
Friday, November 14, 2014
Introduction:
In this article today i will explain how we can send email content as
attachment in PDF format in asp.net.
Description:
To generate the PDF file of email content i am using iTextsharp DLL. To download the DLL Click Here.
Add the reference of DLL to your Project/website.
HTML markup:
Monday, October 20, 2014
Intoduction: In this article today I am going to explain Sql commands and its
types.
Description:
In the previous
article I have explained Copy data from one table to another existing table in sql
server, Get multiple selected values from Listbox in asp.net, Explain cookies in asp.net OR Explain cookies with example
in asp.net and Move items from one listbox to another listbox and vice
versa in asp.net.
Sql commands
are the set of instructions which are connect/ interact with database to
perform specific task.
Types of Sql command:
Sql
commands are grouped into five (5) major categories depending on their
functionality.
Tuesday, October 14, 2014
Introduction: In this article today I will
explain how we can copy data from one table to another existing table sql
server
Description:
In the previous article I have explained Get multiple selected values from Listbox in asp.net, Explain cookies in asp.net OR Explain cookies with example in asp.net and Move items from one listbox to another listbox and vice versa in asp.net.
Syntax to copy all columns from one table to another existing table:
Syntax to copy all columns from one table to another existing table:
Insert into Table2 Select * from Table1;
Syntax
to copy only columns:
Insert into table2(Columns_Name, Columns_Name) select Columns_Name,
Columns_Name from from table1;
Note: Here in the above query we select
data from table 1 and insert it into table 2. Table 1 will be source and table2
will be target table
Example:
I have
two tables:
Old_Student :
Create table
Old_Student
(
Id int not null
primary key,
Student_Name varchar(50),
Student_Address varchar(50),
Phone_No int
)
New_Student:
Create table
New_Student
(
NId int not null primary key,
NStudent_Name varchar(50),
NStudent_Address varchar(50),
NPhone_No int
)
Here now
I want to copy the record from New_Student
table and insert into Old_Student.
Insert into dbo.Old_Student(Student_Name,Student_Address,Phone_No) select
NStudent_Name,NStudent_Address,NPhone_No from dbo.New_Student;
Is this article helpful for you?
If yes post your comment to appreciate my work and fell free to contact me. You can like me on Facebook, Google+, Linkedin and Twitter via hit on Follow us Button and also can get update follow by Email.
Friday, October 10, 2014
Introduction:
In this article today I will explain how we can move items from one listbox to
another listbox and vice versa in asp.net
Description:
In the previous article I have explained Get multiple selected values from Listbox in asp.net, Explain cookies in asp.net OR Explain cookies with example in asp.net and Display number of character left and count word in asp.net multiline textbox using Jquery plugin.
I have added the two listboxes to webform. One listbox
contain the country name and second one city name. In this example I have move single item from
country listbox to city listbox and vice versa. Also move all items to between
each other.
Design the page as Html Markup shown below:
<fieldset>
<legend>ListBox
Example</legend>
<table style="height: 168px; width: 279px">
<tr><td> <asp:ListBox ID="lstbcountry" runat="server" SelectionMode="Multiple"
Height="102px" Width="99px">
<asp:ListItem>India</asp:ListItem>
<asp:ListItem>England</asp:ListItem>
<asp:ListItem>Cuba</asp:ListItem>
<asp:ListItem>Russia</asp:ListItem>
<asp:ListItem>Singapore</asp:ListItem>
</asp:ListBox></td>
<td colspan="2">
<asp:Button ID="Button1" runat="server" Text=">" onclick="Button1_Click" />
<br />
<asp:Button ID="Button3" runat="server" Text=">>" onclick="Button3_Click" />
<br />
<asp:Button ID="Button2"
runat="server" Text="<" onclick="Button2_Click" />
<br />
<asp:Button ID="Button4" runat="server" Text="<<" onclick="Button4_Click" />
</td>
<td><asp:ListBox ID="lstbcity" runat="server" SelectionMode="Multiple"
Height="96px" Width="97px">
<asp:ListItem>Delhi</asp:ListItem>
<asp:ListItem>London</asp:ListItem>
<asp:ListItem>Tokyo</asp:ListItem>
<asp:ListItem>Boston</asp:ListItem>
<asp:ListItem>Moscow</asp:ListItem>
</asp:ListBox></td></tr>
</table>
</fieldset>
Tuesday, October 7, 2014
Introduction:
In this article today I am going to explain how we can get multiple selected values from
Listbox in asp.net
Description:
In the previous article I have explained Format
theemails using StringBulider in asp.net, Disable
copy, cut, paste and drop options in asp.net textbox using Jquery, Explain
cookies in asp.net OR Explain cookies with example in asp.net and Display number of character left and count word in asp.net multiline textbox using Jquery plugin.
Design the webform as given below:
<fieldset style="width:450px">
<legend>Listbox
Example</legend>
Country :
<asp:ListBox
ID="lstcountry"
runat="server"
Width="100px"
SelectionMode="Multiple">
<asp:ListItem>India</asp:ListItem>
<asp:ListItem>China</asp:ListItem>
<asp:ListItem>Cuba</asp:ListItem>
<asp:ListItem>Other</asp:ListItem>
</asp:ListBox>
<br />
<br />
<asp:Button
ID="btnsubmit" runat="server" Text="Get Value" onclick="btnsubmit_Click" />
<asp:Label ID="lblmessage" runat="server"></asp:Label>
</fieldset>
Friday, September 26, 2014
Introduction:
In this article today I am going to explain how we can display number of
character left and count word in asp.net multiline textbox using Jquery plugin
Description:
In the previous article I have explained Format theemails using StringBulider in asp.net, Disable copy,
cut, paste and drop options in asp.net textbox using Jquery, Explain
cookies in asp.net OR Explain cookies with example in asp.net, Explain
viewstate in asp.net OR Viewstate and its advantage or disadvantages and State
Management in Asp.net.
Saturday, September 13, 2014
Introduction: In this article today I am going to explain how we can format the emails using Stringbulider
in asp.net
Description:
In the previous article i have explained Disable copy, cut, paste and drop options in asp.net textbox using Jquery, Explain cookies in asp.net OR Explain cookies with example in asp.net, Explain viewstate in asp.net OR Viewstate and its advantage or disadvantages and State Management in Asp.net.
Firstly check this article
Send email in asp.net
Add a wedform to project
and design the page as shown below:
<fieldset style="width:400px">
<legend>Format
the Emails using StringBuilder Example</legend>
<table>
<tr><td>Email Sent To
:</td><td> <asp:TextBox ID="txtemail"
runat="server"></asp:TextBox></td></tr>
<tr><td></td><td><asp:Button ID="btnsend" runat="server" Text="Send Email" onclick="Button1_Click" /></td></tr>
<tr><td></td><td><label id="lblmessage" runat="server"></label></td></tr>
</table>
</fieldset>
On button click write the
below given code (C#):
using System.Net.Mail;
protected
void Button1_Click(object
sender, EventArgs e)
{
sendemail();
}
public void sendemail()
{
try
{
System.Text.StringBuilder mailBody = new
System.Text.StringBuilder();
mailBody.Append("<table width=\"100%\"
border=\"0\" align=\"center\" cellpadding=\"4\"
cellspacing=\"2\" style=\"font-family:Arial,Verdana\">
");
mailBody.Append("<tr>");
mailBody.Append("<td style='background-color: #f4d687'>");
mailBody.Append("Welcome to Articlemirror,");
mailBody.Append("</tr>");
mailBody.Append("</td>");
mailBody.Append("<tr><td><img src=
\"http://1.bp.blogspot.com/-KVkKmUPkM8M/Uv8SYZ9WCKI/AAAAAAAAA9Q/PienHthBOYU/s1600/am3.png\"
/></td></tr>");
mailBody.Append("<tr><td>Thank you for joining us. You
are the Mebmer of Articlemirror.</td></tr>");
mailBody.Append("<tr><td><a href=\"http://articlemirror.blogspot.in\">Click
here to go Your Webiste</a></td></tr>");
mailBody.Append("<tr><td></td><td><b>Regards,</b></td></tr>");
mailBody.Append("<tr><td></td><td
style='background-color: #0696AF;color:#ffffff'><b>Article
Mirror</b></td></tr>");
mailBody.AppendLine("</table>");
string
Email = ConfigurationManager.AppSettings["Email"].ToString();
string
Emailto = txtemail.Text;
MailMessage
mail = new MailMessage(Email,
Emailto);
mail.Subject = "Article Mirror";
mail.Body =
mailBody.ToString();
mail.IsBodyHtml = true;
SmtpClient
smtp = new SmtpClient();
smtp.Send(mail);
lblmessage.InnerText ="Email send
successfully";
txtemail.Text = "";
}
catch
(Exception ex)
{
}
}
In VB:
Imports
System.Net.Mail
Protected
Sub Button1_Click(ByVal
sender As Object,
ByVal e As
EventArgs) Handles btnsend.Click
sendemail()
End Sub
Public Sub sendemail()
Try
Dim
mailBody As New
System.Text.StringBuilder()
mailBody.Append("<table width=""100%""
border=""0"" align=""center""
cellpadding=""4"" cellspacing=""2""
style=""font-family:Arial,Verdana""> ")
mailBody.Append("<tr>")
mailBody.Append("<td style='background-color: #f4d687'>")
mailBody.Append("Welcome to Articlemirror,")
mailBody.Append("</tr>")
mailBody.Append("</td>")
mailBody.Append("<tr><td><img src=
""http://1.bp.blogspot.com/-KVkKmUPkM8M/Uv8SYZ9WCKI/AAAAAAAAA9Q/PienHthBOYU/s1600/am3.png""
/></td></tr>")
mailBody.Append("<tr><td>Thank you for joining us. You
are the Mebmer of Articlemirror.</td></tr>")
mailBody.Append("<tr><td><a
href=""http://articlemirror.blogspot.in"">Click here to
go Your Webiste</a></td></tr>")
mailBody.Append("<tr><td></td><td><b>Regards,</b></td></tr>")
mailBody.Append("<tr><td></td><td
style='background-color: #0696AF;color:#ffffff'><b>Article
Mirror</b></td></tr>")
mailBody.AppendLine("</table>")
Dim
Email As String
= ConfigurationManager.AppSettings("Email").ToString()
Dim
Emailto As String
= txtemail.Text
Dim
mail As New
MailMessage(Email, Emailto)
mail.Subject = "Article Mirror"
mail.Body = mailBody.ToString()
mail.IsBodyHtml = True
Dim
smtp As New
SmtpClient()
smtp.Send(mail)
lblmessage.InnerText = "Email send successfully"
Catch
ex As Exception
End Try
End Sub
Tags:
Asp.Net,
C#.Net,
Send Email,
VB.Net
Tuesday, September 9, 2014
Introduction:
In this article today I am going to explain how we can disable copy, cut, paste
and drop options in asp.net text box using Jquery
Description:
In the previous article i have explained Explain cookies in asp.net OR Explain cookies with example in asp.net, Explain viewstate in asp.net OR Viewstate and its advantage or disadvantages and State Management in Asp.net
Add a webform to project. Add
the below given script code between head tag of page:
<script
type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$(function
() {
$('.disable').bind('cut copy paste drop', function
(e) {
e.preventDefault();
alert('Cut,Copy,Drop
and Paste options are disabled');
});
});
</script>
After that drag and drop
the text box from Toolbox to webform and design the page as given below:
<fieldset
style="width:400px;height:auto;align:center;">
<legend>Disable
Copy,Paste,Cut and Drop</legend>
<table>
<tr><td>Address</td><td><asp:TextBox ID="txtaddress"
CssClass="disable"
TextMode="MultiLine"
runat="server"></asp:TextBox></td></tr>
<tr><td></td><td>Dummy Text</td></tr>
</table>
</fieldset>
I add the class CssClass="disable" to text box.
Now build and run the project.
Demo:
Is this article helpful for you?
If yes post your comment to appreciate my work and fell free to contact me. You can like me on Facebook, Google+, Linkedin and Twitter via hit on Follow us Button and also can get update follow by Email.
Saturday, August 23, 2014
Introduction: In this article today I will
explain cookies in asp.net OR Explain cookies with example in asp.net
Description:
In the
previous article I have explained Explain viewstate in asp.net OR Viewstate and its advantage or disadvantages, State
Management in Asp.net, Upload and crop image in Asp.net
using Jcrop jquery plugin, Image
preview after upload in asp.net, Validation
for minimum and maximum price using Jquery and Preview
image before upload using Jquery and save in asp.net
Cookies are
the small file of information stored on user’s machine. Cookies allow the web application
to save information for user and use it when needed. It is saved either in memory
of web browser or as a text file in the client’s file system.
Types of Cookies:
1 1.
persist cookies:
It is also known as permanent cookies. Persist cookies are store in hard
disk until they expired or deleted. These are not affected by the browser
setting.
2 2.
Non persist cookies (temporary
cookies):
It is also known as session cookies. It stored in memory of web browser,
as we close the browser it’s lost.
Advantages of cookies:
1. No server resources are required.
2. Cookies are light weight and easy to
implement.
Disadvantages of cookies:
1. Cookies can be disabled on user’s
browser.
2. Not secure because it stored data in
simple text format.
3. Maximum browser support cookies up to
4096 bytes (4 kB) but vary for browser to browser.
4. Maximum number of cookies allowed is
also limited. A website can have maximum 20 cookies per website.
5. No security for case sensitive data.
Example:
Add a webform to project and design the page as mention below:
<fieldset style="width:400px;height:auto;">
<legend>Cookies Example:</legend>
<table>
<tr><td>Name:</td><td><asp:TextBox ID="txtname" runat="server"></asp:TextBox></td></tr>
<tr><td></td><td><asp:Label ID="lblerror" runat="server"></asp:Label></td></tr>
<tr><td><asp:Button ID="btnsubmit" runat="server" Text="Submit" OnClick="btnsubmit_Click" /></td><td><asp:Button ID="btncheck" runat="server" Text="Read Cookies" OnClick="btncheck_Click" /></td></tr>
</table>
</fieldset>
IN C#:
protected void btnsubmit_Click(object sender, EventArgs e)
{
HttpCookie ck = new HttpCookie("book");
ck["bookname"] = txtname.Text;
Response.Cookies.Add(ck);
lblerror.Text = "Cookies Created Successfully";
txtname.Text = string.Empty;
}
protected void btncheck_Click(object sender, EventArgs e)
{
lblerror.Text = "";
HttpCookie ck = Request.Cookies["book"];
string bookname;
if (ck != null)
{
bookname = ck["bookname"];
txtname.Text = bookname;
}
}
IN VB:
Protected Sub
btnsubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
btnsubmit.Click
Dim ck As New HttpCookie("book")
ck("bookname") = txtname.Text
Response.Cookies.Add(ck)
lblerror.Text = "Cookies Created
Successfully"
txtname.Text = String.Empty
End Sub
Protected Sub
btncheck_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
btncheck.Click
lblerror.Text = ""
Dim ck As HttpCookie = Request.Cookies("book")
Dim bookname As String
If ck IsNot Nothing Then
bookname = ck("bookname")
txtname.Text = bookname
End If
End Sub
Create persist cookie:
IN C#:
protected void btnsubmit_Click(object sender, EventArgs e)
{
HttpCookie ck = new HttpCookie("book");
ck["bookname"] = txtname.Text;
//cookie
expire in 1 day
ck.Expires = DateTime.Now.AddDays(1);
Response.Cookies.Add(ck);
lblerror.Text = "Cookies Created Successfully";
txtname.Text = string.Empty;
}
In VB:
Protected Sub
btnsubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
btnsubmit.Click
Dim ck As New HttpCookie("book")
ck("bookname") = txtname.Text
ck.Expires = DateTime.Now.AddDays(1)
Response.Cookies.Add(ck)
lblerror.Text = "Cookies Created
Successfully"
txtname.Text = String.Empty
End Sub
Example to remove persist cookies
before expiration time:
IN C#:
protected void btnsubmit_Click(object sender, EventArgs e)
{
HttpCookie ck = new HttpCookie("book");
ck["bookname"] = txtname.Text;
//Expire
the cookie before expiration time
ck.Expires = DateTime.Now.AddDays(-1);
Response.Cookies.Add(ck);
lblerror.Text = "Cookies Created Successfully";
txtname.Text = string.Empty;
}
IN VB:
Protected Sub
btnsubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
btnsubmit.Click
Dim ck As New HttpCookie("book")
ck("bookname") = txtname.Text
'Expire the cookie before expiration time
ck.Expires = DateTime.Now.AddDays(-1)
Response.Cookies.Add(ck)
lblerror.Text = "Cookies Created
Successfully"
txtname.Text = String.Empty
End Sub
Is this article helpful for you?
If yes post your comment to appreciate my work and fell free to contact me. You can like me on Facebook, Google+, Linkedin and Twitter via hit on Follow us Button and also can get update follow by Email.