Thursday, September 30, 2010

How to work with IFRAMES?

  1. How to pass a value parent to child
  2. How to dynamically load a IFRAME from code behind
  3. How to find which page iframe is embedded in
  4. How to load html page inside aspx page

How to upload a file?

  1. How to upload a file?
  2. How to validate file type in client side?
  3. How to find file size in client side?
  4. How to find file last modified date in client side?
  5. How to find file created date in client side?
  6. How to validate file type in server side?
  7. How to handle files which exceeds the limits?
  8. How to show the selected image without saving the image on the disk?
  9. How to rename the file if the filename exists in the folder while uploading? 

How to build a custom control?

  1. How to build a custom TextBox?
  2. How to build a templated control?
  3. How to implement a collection property?
  4. How to build a custom checkbox control?
  5. How to clone a control?
  6. How to build a resettable panel?
  7. How to build a directory browser? 

How to bubble up events from UserControls to page?

  1. Using delegates
  2. Using bubble event

How to use asp.net caching?

  1. Invalidate response cache based on a condition?
  2. How get/set list item from/to cache

How to work with asp.net calendar?

  1. How to disable weekends
  2. How to disable a day based on criteria
  3. How to disable past days in asp.net calender

How to use asp.net forms authentication?

  1. How to configure simple authentication setup
  2. How to provide a timeout message
  3. How to protect static file types like .xml, .html etc
  4. How to redirect users to certain page based on their username or user role

How to find which control caused a postback

  1. Inside the dedicated event handler
  2. Outside the dedicated event handler

Wednesday, September 29, 2010

How to save details and print a page

Demo:
Useful links:
  1. Opening a window after postback
  2. Java script print function
  3. Apply diffrnet styles whlie printing
  4. Print fit to page and backgrounds
Example:
<%@ Page Language="C#" %>
<html>
<head runat="server">
    <script runat="server">
        private string script = @"
         window.open('{0}','',
                'scrollbars=no,menubar=no, height=600,width=800,resizable=yes,toolbar=no,location=no,status=no');
        ";
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            string m = this.Request.QueryString.Get("mode");
            if (!string.IsNullOrEmpty(m))
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), this.GetType().Name,
                                                                        "window.print();"true);
                this.btnSaveAndPrint.Visible = false;
            }
            else this.btnSaveAndPrint.Visible = true;
        }
        protected void SaveAndPrint(object sender, EventArgs e)
        {
            string page = this.Request.Url.ToString();
            if (page.Contains("?")) page = page + "&mode=print";
            else page = page + "?mode=Print";
            ///
            /// Save your data...
            ///
            Page.ClientScript.RegisterClientScriptBlock(
                this.GetType(),
                this.GetType().Name,
                string.Format(this.script, page),
                true);
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <h1>
        Thank you for purchaing our products</h1>
    <hr />
    <asp:TextBox runat="server" ID="txtName" Text="Name" /><br />
    <asp:TextBox runat="server" ID="txtAddress" Text="Address" /><br />
    <asp:TextBox runat="server" ID="txtEmail" Text="mail@email.com" /><br />
    <asp:TextBox runat="server" ID="txtPhone" Text="0123456789" /><br />
    <hr />
    <p>
        I started this site in 2005 to write down simple but important code snippets which
        I may forget easily. Most of the posts/articles published in this site are not rock
        complicated but they are simple answers to questions, which people may find hard
        to remember How To Do them. Today in 2010, almost all posts/articles are common
        answers to the questions raised in Asp.net Forms. All of these posts/articles been
        tested against certain criteria which suits to subject of the post. But it is essential
        you to understand the domain of the post and apply them in appropriate context.
        Most of the posts have being through couple of reviews after feedback from asp.net
        community users. However I DO NOT provide any warranty for these code snippets,
        which may work in your application context. Use these examples at your own risk.
        However if you find obvious syntax error or typo, please feel free to let me know
        by commenting them, so that I can improve the post for other asp.net community users
        of this site. Please remember you are NOT ALLOWED to COPY entire articles/posts
        and publish them your context without my knowledge and permission.
    </p>
    <asp:Button runat="server" ID="btnSaveAndPrint" Text="Save and Print" OnClick="SaveAndPrint" />
    </form>
</body>
</html>

How to show the progress of long running operation

  1. Simple example - only strat message and end message
  2. Detailed example - including progress bar and step processing results
  3. How to show the progress of a request - using JavaScripts and CSS

How to get around EventValidation error

  1. How to input HTML text with out EventValidation error
  2. How to add/change items to DropDownList in the client side without EventValidation error

Azure Storage Account Types

Defferent Types of Blobs Block blobs store text and binary data. Block blobs are made up of blocks of data that can be managed individually...