Here I am going to explain ,How can you print number Images in Runtime using Asp.Net.
I use a Place Holder control to print number of images in run time.
In previous articles I explained How can you Rotate Image In Asp.Net ? ,
How to Print Data Using JavaScript.
Very Easy way to print number of images in run time.
Download Code Here
Demo :
Step 1: Crate a website .
In .aspx page , Copy and Paste the below code
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title> print Photo Copy</title>
<style type="text/css">
.textbox {
height: 25px;
width: 200px;
text-shadow: 0px 1px 0px #FFF;
outline: none;
background: -webkit-gradient(linear, left top, left bottom, from(#BCBCBE), to(#FFF));
background: -moz-linear-gradient(top, #BCBCBE, #FFF);
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
border: 1px solid #717171;
-webkit-box-shadow: 1px 1px 0px #EFEFEF;
-moz-box-shadow: 1px 1px 0px #efefef;
box-shadow: 1px 1px 0px #EFEFEF;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table class="style1">
<tr>
<td>
</td>
<td>
Print
Photos:</td>
<td>
</td>
</tr>
<tr>
<td style="text-align: right">
Upload Image :</td>
<td>
<asp:FileUpload ID="FileUpload1" runat="server" CssClass="textbox" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="FileUpload1" ErrorMessage="Browse a image"
style="color: #FF0000"></asp:RequiredFieldValidator>
</td>
<td>
</td>
</tr>
<tr>
<td style="text-align: right">
No Of Copy :</td>
<td>
<asp:TextBox ID="txtncopy" runat="server" CssClass="textbox"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="txtncopy" ErrorMessage="How many copy u want"
style="color: #FF0000"></asp:RequiredFieldValidator>
</td>
<td>
</td>
</tr>
<tr>
<td style="text-align: right">
Hight</td>
<td>
<asp:TextBox ID="txthight" runat="server" CssClass="textbox"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="txthight" ErrorMessage="Hight i.e 100"
style="color: #FF0000"></asp:RequiredFieldValidator>
</td>
<td>
</td>
</tr>
<tr>
<td style="text-align: right">
Width</td>
<td>
<asp:TextBox ID="txtwidth" runat="server" CssClass="textbox"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ControlToValidate="txtwidth" ErrorMessage="Width i.e 100"
style="color: #FF0000"></asp:RequiredFieldValidator>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Print"
CssClass="textbox" Height="23px" Width="85px" />
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
</td>
<td>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
Step 2 : Now go to the .aspx.cs page and write the below code.
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string ss = FileUpload1.FileName;
FileUpload1.SaveAs(Server.MapPath(ss));
int x = Convert.ToInt16(txtncopy.Text);
for (int i = 0; i < x; i++)
{
Image img = new Image();
img.Width = Convert.ToInt16(txthight.Text); //Width of image
img.Height = Convert.ToInt16(txtwidth.Text); // Height of image
img.BorderWidth=1;
img.ImageUrl = ss;
PlaceHolder1.Controls.Add(img);
}
}
Now run the program.
If this program help you, Please share.
I use a Place Holder control to print number of images in run time.
In previous articles I explained How can you Rotate Image In Asp.Net ? ,
How to Print Data Using JavaScript.
Very Easy way to print number of images in run time.
Download Code Here
Demo :
Step 1: Crate a website .
In .aspx page , Copy and Paste the below code
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title> print Photo Copy</title>
<style type="text/css">
.textbox {
height: 25px;
width: 200px;
text-shadow: 0px 1px 0px #FFF;
outline: none;
background: -webkit-gradient(linear, left top, left bottom, from(#BCBCBE), to(#FFF));
background: -moz-linear-gradient(top, #BCBCBE, #FFF);
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
border: 1px solid #717171;
-webkit-box-shadow: 1px 1px 0px #EFEFEF;
-moz-box-shadow: 1px 1px 0px #efefef;
box-shadow: 1px 1px 0px #EFEFEF;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table class="style1">
<tr>
<td>
</td>
<td>
Photos:</td>
<td>
</td>
</tr>
<tr>
<td style="text-align: right">
Upload Image :</td>
<td>
<asp:FileUpload ID="FileUpload1" runat="server" CssClass="textbox" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="FileUpload1" ErrorMessage="Browse a image"
style="color: #FF0000"></asp:RequiredFieldValidator>
</td>
<td>
</td>
</tr>
<tr>
<td style="text-align: right">
No Of Copy :</td>
<td>
<asp:TextBox ID="txtncopy" runat="server" CssClass="textbox"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="txtncopy" ErrorMessage="How many copy u want"
style="color: #FF0000"></asp:RequiredFieldValidator>
</td>
<td>
</td>
</tr>
<tr>
<td style="text-align: right">
Hight</td>
<td>
<asp:TextBox ID="txthight" runat="server" CssClass="textbox"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="txthight" ErrorMessage="Hight i.e 100"
style="color: #FF0000"></asp:RequiredFieldValidator>
</td>
<td>
</td>
</tr>
<tr>
<td style="text-align: right">
Width</td>
<td>
<asp:TextBox ID="txtwidth" runat="server" CssClass="textbox"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ControlToValidate="txtwidth" ErrorMessage="Width i.e 100"
style="color: #FF0000"></asp:RequiredFieldValidator>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Print"
CssClass="textbox" Height="23px" Width="85px" />
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
</td>
<td>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
Step 2 : Now go to the .aspx.cs page and write the below code.
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string ss = FileUpload1.FileName;
FileUpload1.SaveAs(Server.MapPath(ss));
int x = Convert.ToInt16(txtncopy.Text);
for (int i = 0; i < x; i++)
{
Image img = new Image();
img.Width = Convert.ToInt16(txthight.Text); //Width of image
img.Height = Convert.ToInt16(txtwidth.Text); // Height of image
img.BorderWidth=1;
img.ImageUrl = ss;
PlaceHolder1.Controls.Add(img);
}
}
Now run the program.
If this program help you, Please share.
No comments:
Post a Comment