Tuesday 26 February 2013

Page Break In Asp.net Repeater

How To insert page break in Asp.Net Repeater??????

<asp:Repeater ID="RPTPrintNotice" runat="server">
                        <HeaderTemplate>
                            <table style="font-size: 12pt; width: 8.3in; height: 11.7in;" align="center">
<-->  Define Page Size here is width: 8.3in; height: 11.7in<-->
                        </HeaderTemplate>
                        <ItemTemplate>
                            <tr>
                                   <td colspan="4" style="text-align: left; height: 3px;">
                                    <asp:Image ID="Image1" runat="server" ImageUrl="~/Images/line.GIF"      Height="1px" Width="820px" /></td>
                            </tr>
                            <tr>
                                <td colspan="4" align="center">
                                    <asp:Label ID="lblAllowedBy" runat="server" Text='<%#Eval("AllowedBy") %>'></asp:Label></td>
                            </tr>
                            <tr>
                                <td colspan="4">
<--> Provide height according to your page like A4(11.7in *8.3in )  or A5 or givre line break<-->
                                    <br />
                                    <br />
                                    <br />
                                    <br />
                                    <br />
                                    <br />                                
                                    <p style="page-break-before: always">
                                    </p>
                                </td>
                            </tr>
                        </ItemTemplate>
                        <FooterTemplate>
                            </table>
                        </FooterTemplate>
                        <SeparatorTemplate>
                            <p style="page-break-before: always">
                            </p>
                        </SeparatorTemplate>
                    </asp:Repeater>

Any Query regraded to this contact ayush.ssnghl@gmail.com

Synchronization in Application State Using ASP.NET

How to implement Synchronization in application state?
In the above code, a page counter would probably not keep an accurate count. For example, if two clients requested the page at the same time. Then deadlock will occur. We can avoid deadlock occurrence while we updating application variable by multiple users with help of Lock() and UnLock().
Adding the following code with lock and unlock method.
protected void Page_Load(object sender, System.EventArgs e)
    {
        Application.Lock();
        int count = 0;
        if (Application("Pagecount") != null)
        {
            count = Convert.ToInt32(Application("Pagecount"));
        }
        count += 1;
        Application("Pagecount") = count;
        Application.UnLock();
        Label1.Text = "Total Page Visited: " + count.ToString() + "Times";
    }