Thursday, October 20, 2011

ASP.NET - UpdateProgress with ModalPopupExtender

Watch this example on Youtube: 

Add Update Progress, Modal Popup Extender and Panel with image and label

    whole code looks like:

    <div class="ControlsCenter">
        <asp:UpdateProgress ID="UpdateProgress1" runat="server" DisplayAfter="0" AssociatedUpdatePanelID="UpdatePanel1">
        <asp:ModalPopupExtender ID="modalExtender" runat="server" TargetControlID="UpdateProgress1"
            PopupControlID="Panel1" DropShadow="true" BackgroundCssClass="modalBackground">
        <asp:Panel ID="Panel1" runat="server" CssClass="modalExtender">
            <img alt="Processing" src="../Images/working.gif" />
            <br />
            <asp:Label ID="lblProcessing" runat="server" Text="Processing..." CssClass="TitleBar"></asp:Label>

     Modal is executed when Update Progress is called and displays controls from Panel therefore:

    class="ControlsCenter" will center all controls
        margin-left: auto;
        margin-right: auto;
        width: 50em;

    BackgroundCssClass="modalBackground" will shadow whole screen
        background-color: Gray;
        filter: alpha(opacity=50);
        opacity: 0.50;

    CssClass="modalExtender" will just centralize all controls inside
        border-width: 1px;
        border-style: solid;
        background-color: #FFFFFF;
        position: absolute;

    add the following javascript code just after form tag

    <script type="text/javascript">

        function showPopup(sender, args){
         var ModalControl ='<%= modalExtender.ClientID %>';  

        function hidePopup(sender, args) {
            var ModalControl ='<%= modalExtender.ClientID %>';

ASP.NET - Add paging

set AllowPaging="True"

and implement the following procedure

    Private Sub gvReport_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles gvReport.PageIndexChanging
        gvReport.PageIndex = e.NewPageIndex
        gvReport.DataSource = ds.Tables("TableName").DefaultView
    End Sub

ASP.NET - GridView - Add scrollbar and freeze header

To add scrollbar and freeze header of gridview

modify DocType <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
put your grid inside    <div id="Div1" style="OVERFLOW: auto; HEIGHT: 700px">

   <div id="Div1" style="OVERFLOW: auto; HEIGHT: 700px">
                <asp:GridView ID="gvReport" runat="server" AllowPaging="True" CssClass="dataGrid">

Tuesday, October 18, 2011

CSS - different align issues - align divs and controls inside div

div will start from the right, controls inside it will start from the left
<div style="float: right;">
div will start from the right, controls inside it will start from the right
<div style="float: right; text-align:right;">

Friday, October 7, 2011

MS SQL - Convert Date to Month Name and sort

Convert date to month:
DATENAME(month, TableName.DateFieldName) AS [Month Name]

Full statement with sorting by month:
TableName.DateFieldName) AS [Month Name]

Thursday, October 6, 2011

C# - .NET - Wrong Date Format

Culture settings in visual studio for same reasons are not the same as in regional settings. In regional settings it is set to en-US and while executing the following code while running the page CultureInfo.CurrentCulture I am getting en-CA
Not sure why this is happening - couldn't find anything online, but a way around was to modify web.config
<globalization requestEncoding="utf-8" responseEncoding="utf-8" culture="en-US"/>