Wednesday, 13 April 2016

Set Spinner

Set Spinner for page post back

1] Past below code on .cs page

protected override void Render(HtmlTextWriter writer)
        {
            base.Render(writer);
            if (!ScriptManager.GetCurrent(this.Page).IsInAsyncPostBack)
            {
                string script = "";
                script = @"
                            var ITEMLISTINGBUTTONID;
                                                     
                         with(Sys.WebForms.PageRequestManager.getInstance()){
                             add_beginRequest(onBeginRequest);
                             add_endRequest(onEndRequest);
                         }
                         function onBeginRequest(sender, args){                          
                            $('#progressDiv').css('display','block');
                            $('#hourlyglass').css('display','block'); 
                         }
                         function onEndRequest(sender, args){                         
                            $('#progressDiv').css('display','none');
                            $('#hourlyglass').css('display','none');

                         }
                        ";
                this.Page.ClientScript.RegisterStartupScript(this.GetType(), "HideSimpleAJAXWebPartUDP", script, true);

            }
        }

2] css

<style type="text/css">
  #hourlyglass
    {
        width: 100%;
        background-color: rgba(0,0,0,0.4);
        z-index: 120;
        height: 100%;
        top: 0px;
        left: 0px;
        position: absolute;
        display: none;
    }
    .loader-small
    {
        z-index: 200;
        position: absolute;   
         /*top: 150px;*/
        /*left: 10%;*/
        /*margin: auto;*/
        margin-left:45%;
        margin-top:20%;
        border: 2px solid #9CA3AB;
        padding: 5px;
        text-align: center;
        display: none;
        background-color: white
        width: 150px;
        box-shadow: 0px 1px 3px #9099A2;
        font-weight: bold;
    }
   </style>

3] Past below HTML code within a page Div

<div id='hourlyglass'>
    <div id='progressDiv' class='loader-small'>
    <img src='/Style Library/DNS/images/12345.gif' />
    <br>
    Please wait...
    </div>
    </div>



Note : 12345.gif is a image name which should be present in respective path which you mentioned in <img src=” “/> i.e /Style Library/DNS/images/12345.gif an dit should publish with major version.

No comments:

Post a Comment