locked
print my datalist each box height 2.3cm width 4.7cm and A4 page has each 4 label in horizontal RRS feed

  • Question

  • User-807418713 posted

    Hello

    This Is My SQL Code

    USE [Purchase_Sales]
    GO
    /****** Object:  Table [dbo].[Table1]    Script Date: 11/27/2018 18:27:05 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    SET ANSI_PADDING ON
    GO
    CREATE TABLE [dbo].[Table1](
    	[ID] [int] IDENTITY(1,1) NOT NULL,
    	[Item_Name] [varchar](50) NULL,
    	[BC] [varchar](50) NULL,
     CONSTRAINT [PK_Table1] PRIMARY KEY CLUSTERED 
    (
    	[ID] ASC
    )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    GO
    SET ANSI_PADDING OFF
    GO
    SET IDENTITY_INSERT [dbo].[Table1] ON
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (1, N'Apple', N'MS1118-001')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (2, N'Mango', N'MS1118-002')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (3, N'Orange', N'MS1118-003')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (4, N'Lemon', N'MS1118-004')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (5, N'Apple', N'MS1118-001')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (6, N'Mango', N'MS1118-002')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (7, N'Orange', N'MS1118-003')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (8, N'Lemon', N'MS1118-004')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (9, N'Apple', N'MS1118-001')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (10, N'Mango', N'MS1118-002')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (11, N'Orange', N'MS1118-003')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (12, N'Lemon', N'MS1118-004')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (13, N'Apple', N'MS1118-001')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (14, N'Mango', N'MS1118-002')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (15, N'Orange', N'MS1118-003')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (16, N'Lemon', N'MS1118-004')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (17, N'Apple', N'MS1118-001')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (18, N'Mango', N'MS1118-002')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (19, N'Orange', N'MS1118-003')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (20, N'Lemon', N'MS1118-004')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (21, N'Apple', N'MS1118-001')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (22, N'Mango', N'MS1118-002')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (23, N'Orange', N'MS1118-003')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (24, N'Lemon', N'MS1118-004')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (25, N'Apple', N'MS1118-001')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (26, N'Mango', N'MS1118-002')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (27, N'Orange', N'MS1118-003')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (28, N'Lemon', N'MS1118-004')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (29, N'Apple', N'MS1118-001')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (30, N'Mango', N'MS1118-002')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (31, N'Orange', N'MS1118-003')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (32, N'Lemon', N'MS1118-004')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (33, N'Apple', N'MS1118-001')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (34, N'Mango', N'MS1118-002')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (35, N'Orange', N'MS1118-003')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (36, N'Lemon', N'MS1118-004')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (37, N'Apple', N'MS1118-001')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (38, N'Mango', N'MS1118-002')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (39, N'Orange', N'MS1118-003')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (40, N'Lemon', N'MS1118-004')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (41, N'Apple', N'MS1118-001')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (42, N'Mango', N'MS1118-002')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (43, N'Orange', N'MS1118-003')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (44, N'Lemon', N'MS1118-004')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (45, N'Apple', N'MS1118-001')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (46, N'Mango', N'MS1118-002')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (47, N'Orange', N'MS1118-003')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (48, N'Lemon', N'MS1118-004')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (49, N'Apple', N'MS1118-001')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (50, N'Mango', N'MS1118-002')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (51, N'Orange', N'MS1118-003')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (52, N'Lemon', N'MS1118-004')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (53, N'Apple', N'MS1118-001')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (54, N'Mango', N'MS1118-002')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (55, N'Orange', N'MS1118-003')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (56, N'Lemon', N'MS1118-004')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (57, N'Apple', N'MS1118-001')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (58, N'Mango', N'MS1118-002')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (59, N'Orange', N'MS1118-003')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (60, N'Lemon', N'MS1118-004')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (61, N'Apple', N'MS1118-001')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (62, N'Mango', N'MS1118-002')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (63, N'Orange', N'MS1118-003')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (64, N'Lemon', N'MS1118-004')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (65, N'Apple', N'MS1118-001')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (66, N'Mango', N'MS1118-002')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (67, N'Orange', N'MS1118-003')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (68, N'Lemon', N'MS1118-004')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (69, N'Apple', N'MS1118-001')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (70, N'Mango', N'MS1118-002')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (71, N'Orange', N'MS1118-003')
    INSERT [dbo].[Table1] ([ID], [Item_Name], [BC]) VALUES (72, N'Lemon', N'MS1118-004')
    SET IDENTITY_INSERT [dbo].[Table1] OFF

    This Is My ASPX Code

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Test_BC.aspx.cs" Inherits="NN_JC" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head id="Head1" runat="server">
    
        <title>BarCode Sticker Print Page</title>
        
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
        <script type="text/javascript">
            function Print() {
                var count = $('[id*=tblCustomer]').length;
                var pagebreakcount = 4;
                var i = 1;
                $('[id*=tblCustomer]').each(function () {
                    if (i % pagebreakcount == 0) {
                        $(this).attr('style', 'page-break-after: always');
                    }
                    i++;
                });
                var divContents = document.getElementById("dvCustomers").innerHTML;
                var printWindow = window.open('', '', 'height=2000,width=4000');
                printWindow.document.write(divContents);
                printWindow.document.close();
                printWindow.print();
                Redirect();
            };
            function Redirect() {
                setTimeout(function () {
                    location.href = location.href;
                }, 5000);
            }
        </script>
        
    
    </head>
    
    
    
    
    
    <body style="font-size: 12pt; font-family: Times New Roman">
        <form id="form1" runat="server">
        <div>
        
            <table>
                <tr>
                    <td colspan="5" rowspan="2">
                        <asp:Label ID="Label4" runat="server" Font-Bold="True" Font-Names="Palatino Linotype"
                            Font-Size="12pt" ForeColor="Red" Style="text-align: center" Text="Todays Date"
                            Width="116px"></asp:Label><asp:TextBox ID="TextBox2" runat="server" autocomplete="off" Width="103px"></asp:TextBox>
            
             
           <asp:Button ID="btnPrint" Text="Print" runat="server" OnClick="Print" />
                        
                    </td>
                </tr>
               
            </table>
            
        
        
        <div id="dvCustomers"> 
         <asp:DataList ID="dlCustomers"  runat="server" RepeatColumns="4" RepeatDirection="Horizontal"  >        
            <itemtemplate>        
            <table id="tblCustomer" style="width:4cm;height:2cm">
                        <tr>
                        <td>
                        <asp:Label ID="Label2" runat="server" Font-Size="10px"  Font-Names="Palatino Linotype" Text='<%# Bind("Item_Name") %>'></asp:Label>
                        <br />
                        <asp:Label ID="Label1" runat="server" Font-Size="15px" Font-Names="MRV Code39extMA" Text='<%# Bind("BC") %>'></asp:Label>
                        </td>
                        </tr>                   
            </table> 
            </itemtemplate>
            </asp:DataList>
      </div>
    </div>
           
           
         
        </form>
    </body>
    </html>
    

    This Is My Code Behind

    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.Data.SqlClient;
    using System.IO;
    
    public partial class NN_JC : System.Web.UI.Page
    {    
    
        private void binddatalist()
        {
           
                DataSet dt = new DataSet();
                SqlConnection con1 = new SqlConnection(ConfigurationManager.ConnectionStrings["CHEMIMSConnectionString"].ConnectionString);
                con1.Open();
                SqlCommand cmd1 = new SqlCommand("select Item_Name,BC from Table1", con1);
                SqlDataAdapter ada1 = new SqlDataAdapter(cmd1);
                ada1.Fill(dt);
                dlCustomers.DataSource = dt;
                dlCustomers.DataBind();
                con1.Close();
            
        }  
     
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                TextBox2.Text = DateTime.Now.ToString("dd-MMM-yyyy");
    
                binddatalist();
    
             
            }
        }
    
        protected void Print(object sender, EventArgs e)
        {
            dlCustomers.RepeatColumns = 4;
            this.ClientScript.RegisterStartupScript(this.GetType(), "Print", "Print()", true);
        }
       
        protected void refresh_Click(object sender, EventArgs e)
        {
            Response.Redirect(Request.RawUrl);
        }
     
    }
    

    This Is My Output On Print

    In my A4 page I have 4 box horizontal and 12 box vertical. Each box size is 2.3cm height and 4.7cm width

    I want to print my barcode inside each box with this  perfect size 2.3cm height and 4.7cm width

    where to apply 2.3cm height and 4.7cm width so that while print it comes perfect in box.

    Thanking You

    Wednesday, November 28, 2018 12:35 PM

Answers

  • User-893317190 posted

    Hi Gopi.MCA,

    I have simulate your p4 page to make a layout, please change the css property according to your requirement.

    <body style="font-size: 12pt; font-family: Times New Roman">
        <form id="form1" runat="server">
        <div >
        
            <table>
                <tr>
                    <td colspan="5" rowspan="2">
                        <asp:Label ID="Label4" runat="server" Font-Bold="True" Font-Names="Palatino Linotype"
                            Font-Size="12pt" ForeColor="Red" Style="text-align: center" Text="Todays Date"
                            Width="116px"></asp:Label><asp:TextBox ID="TextBox2" runat="server" autocomplete="off" Width="103px"></asp:TextBox>
            
             
           <asp:Button ID="btnPrint" Text="Print" runat="server" OnClick="Print" />
                        
                    </td>
                </tr>
               
            </table>
            
            <%-- My A4 page size: width 210mm, length 297mm    Top margin 5mm: 5:padding-top:5mm --%>
        <div id="dvCustomers" style="width:210mm;padding-top:5mm;padding-bottom:5px;box-sizing:border-box;padding-left:15px" class="border"> 
            
         <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
            <%-- Side margin 4.5mm -> padding:0 4.5px --%>
            <div class="row " style="width:210mm;padding:0 10px">
            <asp:Repeater ID="Repeater1" runat="server">
            <itemtemplate>                  
                   <%-- Vertical Pitch 24.0 mm ->  height:24.0 mm;--%>
                <div class="col-3 " style="padding:0px 2px;height:16.5mm;">
                    <%-- please change border-radius according to your own requirement --%>
                           <div style="text-align:center;border-radius:1em;height:100%;padding:0px 5px" class=" border">
                       <%-- Label height 24mm 
                            Label width 48mm 
                           Number across: 4
                            Number down: 12
                           please change the font-size according to the label height and width   --%>
                        <asp:Label ID="Label2" runat="server" Font-Size="10px"  Font-Names="Palatino Linotype" Text='<%# Bind("Item_Name") %>'></asp:Label>
                        <br />
                        <asp:Label ID="Label1" runat="server" Font-Size="15px" Font-Names="MRV Code39extMA" Text='<%# Bind("BC") %>'></asp:Label>
                     
    
             </div>
                    </div>
            </itemtemplate>
         </asp:Repeater>
                </div>
      </div>
    </div>
           
           
         
        </form>
    </body>
    </html>

    The result.

    Best regards,

    Ackerly Xu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, December 4, 2018 5:53 AM

All replies

  • User-893317190 posted

    Hi Gopi.MCA,

    I haven't seen your barcode ,but if you want to align your content in datalist , you could try the code below.

     <table id="tblCustomer" style="width:4.7cm;height:2.3cm;text-align:center" >
                        <tr>
                        <td>
                        <asp:Label ID="Label2" runat="server" Font-Size="10px"  Font-Names="Palatino Linotype" Text='<%# Bind("Item_Name") %>'></asp:Label>
                        <br />
                        <asp:Label ID="Label1" runat="server" Font-Size="15px" Font-Names="MRV Code39extMA" Text='<%# Bind("BC") %>'></asp:Label>
                        </td>
                        </tr>                   
            </table> 

    Below is my setting in print.

    Best regards,

    Ackerly Xu

    Thursday, November 29, 2018 3:25 AM
  • User-807418713 posted

    Hello

    In my scenario its coming like this 

    see the below screenshot and let me know what to do

    In my A4 page I have 4 box horizontal and 12 box vertical. Each box size is 2.3cm height and 4.7cm width then i want A4 page setup inside this barcode

    Thursday, November 29, 2018 1:17 PM
  • User-807418713 posted

    Hello
    This is my data

    <asp:Label ID="Label2" runat="server" Font-Size="10px" Font-Names="Palatino Linotype" Text='<%# Bind("Item_Name") %>'></asp:Label>
    <br />
    <asp:Label ID="Label1" runat="server" Font-Size="15px" Font-Names="MRV Code39extMA" Text='<%# Bind("BC") %>'></asp:Label>

    My A4 Page Size Is Width= 21 CM and Height = 29.7 CM.

    Each A4 Page Has 4 Horizontal Label Each Label Size Is Width 4.7cm and Height 2.3cm

    So In Total A4 Page 48 Sticker

    Give Me One design It would be needful on page it should all if i click print it should come perfect in a4 page.

    Please give me a page it would be thank so much for you

    Note CM= centimeter

    Thursday, November 29, 2018 2:05 PM
  • User-893317190 posted

    Hi Gopi.MCA,

    I'm sorry, I haven't told you I have changed your script.

    Because I find the script will change the layout of the box on the right.

    Below is my code. I don't know what you want to do use the script,but if you want your box on the right look well,you had better comment out it

     function Print() {
                var count = $('[id*=tblCustomer]').length;
                var pagebreakcount = 4;
                var i = 1;
                //$('[id*=tblCustomer]').each(function () {
                //    if (i % pagebreakcount == 0) {
                //        $(this).attr('style', 'page-break-after: always');
                //    }
                //    i++;
                //});
                var divContents = document.getElementById("dvCustomers").innerHTML;
                var printWindow = window.open('', '', 'height=2000,width=4000');
                printWindow.document.write(divContents);
                printWindow.document.close();
                printWindow.print();
                Redirect();
            };
            function Redirect() {
                setTimeout(function () {
                    location.href = location.href;
                }, 5000);
            }

     Best regards,

    Ackerly Xu

    Friday, November 30, 2018 1:16 AM
  • User-807418713 posted
    Hello

    It would be needful if you create one page you can use anything like data list or repeater or grid view

    I have A4page I want to print data perfect inside while print

    <asp:Label ID="Label2" runat="server" Font-Size="10px" Font-Names="Palatino Linotype" Text='<%# Bind("Item_Name") %>'></asp:Label>
    <br />
    <asp:Label ID="Label1" runat="server" Font-Size="15px" Font-Names="MRV Code39extMA" Text='<%# Bind("BC") %>'></asp:Label>

    My A4 Page Size Is Width= 21 CM and Height = 29.7 CM.

    Each A4 Page Has 4 Horizontal Label Each Label Size Is Width 4.7cm and Height 2.3cm

    So In Total A4 Page 48 Sticker

    Give Me One design It would be needful on page it should all if i click print it should come perfect in a4 page.

    Please give me a page it would be thank so much for you

    Note CM= centimeter


    Please give me complete code it would be needful
    Friday, November 30, 2018 3:49 AM
  • User-893317190 posted

    Hi Gopi.MCA,

    Don't understand what you mean by  print data perfect inside .

    I have tried code , and use chrome printer to print the repeater as pdf.

    Below is the result.

    You could try the code below, the table lays in the middle in the page,but I'm not sure whether it will still in the middle after you print it.

    <script type="text/javascript">
            function Print() {
                var count = $('[id*=tblCustomer]').length;
                var pagebreakcount = 4;
                var i = 1;
                //$('[id*=tblCustomer]').each(function () {
                //    if (i % pagebreakcount == 0) {
                //        $(this).attr('style', 'page-break-after: always');
                //    }
                //    i++;
                //});
                var divContents = document.getElementById("dvCustomers")
                var printWindow = window.open('', '', 'height=2000,width=612');
                printWindow.document.body.appendChild(divContents);
                printWindow.document.close();
                printWindow.print();
                Redirect();
            
            };
            function Redirect() {
                setTimeout(function () {
                    location.href = location.href;
                }, 5000);
            }
        </script>
        
    
    </head>
    
    
    
    
    
    <body style="font-size: 12pt; font-family: Times New Roman">
        <form id="form1" runat="server">
        <div >
        
            <table>
                <tr>
                    <td colspan="5" rowspan="2">
                        <asp:Label ID="Label4" runat="server" Font-Bold="True" Font-Names="Palatino Linotype"
                            Font-Size="12pt" ForeColor="Red" Style="text-align: center" Text="Todays Date"
                            Width="116px"></asp:Label><asp:TextBox ID="TextBox2" runat="server" autocomplete="off" Width="103px"></asp:TextBox>
            
             
           <asp:Button ID="btnPrint" Text="Print" runat="server" OnClick="Print" />
                        
                    </td>
                </tr>
               
            </table>
            
        
        
        <div id="dvCustomers" > 
         <asp:DataList ID="dlCustomers"  runat="server" RepeatColumns="4" RepeatDirection="Horizontal"  CssClass="row"  Width="612" style="margin:0 auto" >        
            <itemtemplate>        
         <%--   <table id="tblCustomer" style="width:4cm;height:2cm;text-align:center" >--%>
                       <%-- <tr>--%>
                        <td style="text-align:center;width:4cm;height:2cm;" >
                        <asp:Label ID="Label2" runat="server" Font-Size="10px"  Font-Names="Palatino Linotype" Text='<%# Bind("Item_Name") %>'></asp:Label>
                        <br />
                        <asp:Label ID="Label1" runat="server" Font-Size="15px" Font-Names="MRV Code39extMA" Text='<%# Bind("BC") %>'></asp:Label>
                        </td>
                     <%--   </tr>  --%>                 
        <%--    </table> 
                --%>
            </itemtemplate>
            </asp:DataList>
      </div>
    </div>
           
           
         
        </form>
    </body>

    You could also try bootstrap, it could help you make a good layout responsively.

    https://getbootstrap.com/docs/4.1/layout/overview/

    Best regards,

    Ackerly Xu

    Friday, November 30, 2018 6:44 AM
  • User-807418713 posted

    Hello

    This is my aspx page

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Test_BC.aspx.cs" Inherits="NN_JC" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head id="Head1" runat="server">
    
        <title>BarCode Sticker Print Page</title>
        
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
        <script type="text/javascript">
           function Print() {
                var count = $('[id*=tblCustomer]').length;
                var pagebreakcount = 4;
                var i = 1;
                //$('[id*=tblCustomer]').each(function () {
                //    if (i % pagebreakcount == 0) {
                //        $(this).attr('style', 'page-break-after: always;');
                //    }
                //    i++;
                //});
                var divContents = document.getElementById("dvCustomers").innerHTML;
                var printWindow = window.open('', '', 'height=2000,width=4000');
                printWindow.document.write(divContents);
                printWindow.document.close();
                printWindow.print();
                Redirect();
            };
            function Redirect() {
                setTimeout(function () {
                    location.href = location.href;
                }, 5000);
            }
        </script>
        
    
    
    </head>
    
    
    
    
    
    <body style="font-size: 12pt; font-family: Times New Roman">
        <form id="form1" runat="server">
        <div>
        
            <table>
                <tr>
                    <td colspan="5" rowspan="2">
                        <asp:Label ID="Label4" runat="server" Font-Bold="True" Font-Names="Palatino Linotype"
                            Font-Size="12pt" ForeColor="Red" Style="text-align: center" Text="Todays Date"
                            Width="116px"></asp:Label><asp:TextBox ID="TextBox2" runat="server" autocomplete="off" Width="103px"></asp:TextBox>
            
            
             
           <asp:Button ID="btnPrint" Text="Print" runat="server" OnClick="Print" />
                        
                    </td>
                </tr>
               
            </table>
            
        
        
        <div id="dvCustomers" > 
         <asp:DataList ID="dlCustomers"  runat="server" RepeatColumns="4" RepeatDirection="Horizontal"  style="width: 21cm;height: 29.7cm;  margin: 3.8mm 3.8mm 3.8mm 3.8mm" >        
            <itemtemplate> 
                   
            <table id="tblCustomer"  >
                        <tr>
                        <td style="width:4.8cm;height:2.34cm;" >
                        <asp:Label ID="Label2" runat="server" Font-Size="12px"  Font-Names="Palatino Linotype" Text='<%# Bind("Item_Name") %>'></asp:Label>
                        <br />
                        <asp:Label ID="Label1" runat="server" Font-Size="15px" Font-Names="MRV Code39extMA" Text='<%# Bind("BC") %>'></asp:Label>
                        </td>
                        </tr>                   
            </table> 
            </itemtemplate>
            </asp:DataList>
      </div>
    </div>
           
           
         
        </form>
    </body>
    </html>
    

    This is my output coming 

    While printing first page coming perfect but second page not what to do is i have to set anything  page-break-after: always;

    Or Else Please Give Me One Sample Page that should be in A4 Page Size Width : 210 mm X length : 297mm And This  a4 page has four label each label size width : 48mm * length: 24mm, and all side equal margin is  4mm it would be very thankful if you give me one complete new sample page with datalist or repater or gridview format.

    Thanking You

    Friday, November 30, 2018 3:48 PM
  • User-893317190 posted

    Hi Gopi.MCA,

    You could use chrome print to set the margin.Please use the toolbar on the left.Set margins on the left to custom, and move the blue line(which will occur after set it to custom)  on your page. You could also try the scale property.

    Best regards,

    Ackerly Xu

    Monday, December 3, 2018 1:45 AM
  • User-807418713 posted
    Hello
    Thanks for your reply

    Can you give me any other best sample page because many customer will access our webpage they can't do this setting so any other best sample aspx page with complete code it would be needful

    Thank You
    Monday, December 3, 2018 4:25 AM
  • User-807418713 posted

    My A4 page size: width 210mm, length 297mm

    48*24

    Top margin mm: 5
    Side margin mm: 4.5
    Vertical Pitch mm: 24.0
    Horizontal Pitch mm: 51.0
    Label height mm: 24.0
    Label width mm: 48.0
    Number across: 4
    Number down: 12

    My A4 Page Look Like This

    Monday, December 3, 2018 5:22 AM
  • User-893317190 posted

    Hi Gopi.MCA,

    I have used bootstrap to make a layout.You could change the style according to your requirement.Please keep the boostrap css in the div dvCustomers to pass to the opened window.

    <head runat="server">
       <title>BarCode Sticker Print Page</title>
        
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
        <script type="text/javascript">
            function Print() {
                var count = $('[id*=tblCustomer]').length;
                var pagebreakcount = 4;
                var i = 1;
                //$('[id*=tblCustomer]').each(function () {
                //    if (i % pagebreakcount == 0) {
                //        $(this).attr('style', 'page-break-after: always');
                //    }
                //    i++;
                //});
                var divContents = document.getElementById("dvCustomers").innerHTML
                var printWindow = window.open('', '', 'height=2000,width=612');
                printWindow.document.write(divContents);
                printWindow.document.close();
                printWindow.print();
    
              
                Redirect();
            
            };
            function Redirect() {
                setTimeout(function () {
                    location.href = location.href;
                }, 5000);
            }
        </script>
        
        
    </head>
    
    
    <body style="font-size: 12pt; font-family: Times New Roman">
        <form id="form1" runat="server">
        <div >
        
            <table>
                <tr>
                    <td colspan="5" rowspan="2">
                        <asp:Label ID="Label4" runat="server" Font-Bold="True" Font-Names="Palatino Linotype"
                            Font-Size="12pt" ForeColor="Red" Style="text-align: center" Text="Todays Date"
                            Width="116px"></asp:Label><asp:TextBox ID="TextBox2" runat="server" autocomplete="off" Width="103px"></asp:TextBox>
            
             
           <asp:Button ID="btnPrint" Text="Print" runat="server" OnClick="Print" />
                        
                    </td>
                </tr>
               
            </table>
            
    
        <div id="dvCustomers" class="container" > 
            
         <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
            <div class="row " style="width:210mm;">  
    <!--height of the whole div--> <asp:Repeater ID="Repeater1" runat="server"> <itemtemplate>
    <!--height of every box--> <div style="text-align:center;height:16.5mm;" class="col-3"> <asp:Label ID="Label2" runat="server" Font-Size="10px" Font-Names="Palatino Linotype" Text='<%# Bind("Item_Name") %>'></asp:Label> <br /> <asp:Label ID="Label1" runat="server" Font-Size="15px" Font-Names="MRV Code39extMA" Text='<%# Bind("BC") %>'></asp:Label> </div> </itemtemplate> </asp:Repeater> </div> </div> </div>

    The result.

    Best regards,

    Ackerly Xu

    Monday, December 3, 2018 9:32 AM
  • User-807418713 posted

    Hello

    Tried Again Not Working, This is my page details

    My A4 page size: width 210mm, length 297mm

    48*24

    Top margin 5mm: 5
    Side margin 4.5mm 
    Vertical Pitch 24.0 mm 
    Horizontal Pitch 51.0mm 
    Label height 24mm 
    Label width 48mm 
    Number across: 4
    Number down: 12

    My A4 Page Look Like This

    Monday, December 3, 2018 11:54 AM
  • User-893317190 posted

    Hi Gopi.MCA,

    I have simulate your p4 page to make a layout, please change the css property according to your requirement.

    <body style="font-size: 12pt; font-family: Times New Roman">
        <form id="form1" runat="server">
        <div >
        
            <table>
                <tr>
                    <td colspan="5" rowspan="2">
                        <asp:Label ID="Label4" runat="server" Font-Bold="True" Font-Names="Palatino Linotype"
                            Font-Size="12pt" ForeColor="Red" Style="text-align: center" Text="Todays Date"
                            Width="116px"></asp:Label><asp:TextBox ID="TextBox2" runat="server" autocomplete="off" Width="103px"></asp:TextBox>
            
             
           <asp:Button ID="btnPrint" Text="Print" runat="server" OnClick="Print" />
                        
                    </td>
                </tr>
               
            </table>
            
            <%-- My A4 page size: width 210mm, length 297mm    Top margin 5mm: 5:padding-top:5mm --%>
        <div id="dvCustomers" style="width:210mm;padding-top:5mm;padding-bottom:5px;box-sizing:border-box;padding-left:15px" class="border"> 
            
         <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
            <%-- Side margin 4.5mm -> padding:0 4.5px --%>
            <div class="row " style="width:210mm;padding:0 10px">
            <asp:Repeater ID="Repeater1" runat="server">
            <itemtemplate>                  
                   <%-- Vertical Pitch 24.0 mm ->  height:24.0 mm;--%>
                <div class="col-3 " style="padding:0px 2px;height:16.5mm;">
                    <%-- please change border-radius according to your own requirement --%>
                           <div style="text-align:center;border-radius:1em;height:100%;padding:0px 5px" class=" border">
                       <%-- Label height 24mm 
                            Label width 48mm 
                           Number across: 4
                            Number down: 12
                           please change the font-size according to the label height and width   --%>
                        <asp:Label ID="Label2" runat="server" Font-Size="10px"  Font-Names="Palatino Linotype" Text='<%# Bind("Item_Name") %>'></asp:Label>
                        <br />
                        <asp:Label ID="Label1" runat="server" Font-Size="15px" Font-Names="MRV Code39extMA" Text='<%# Bind("BC") %>'></asp:Label>
                     
    
             </div>
                    </div>
            </itemtemplate>
         </asp:Repeater>
                </div>
      </div>
    </div>
           
           
         
        </form>
    </body>
    </html>

    The result.

    Best regards,

    Ackerly Xu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, December 4, 2018 5:53 AM