Thursday, December 28, 2017

ASP.NET GridView : Change Command Field to Template Field

For example, with a Delete button.

From:

<asp:CommandField ShowDeleteButton="True" />


To:


<asp:TemplateField>
                                                    <ItemTemplate>
                                                        <asp:LinkButton ID="lbDelete" runat="server" CommandName="Delete"
                                                            Text="Delete">
                                                        </asp:LinkButton>
                                                    </ItemTemplate>
                                                </asp:TemplateField>

Sunday, December 3, 2017

ASP.NET AJAX Cheat Sheet

REMEMBER: Only the stuff inside the UpdatePanel gets updated from the postback.
 
In Design View: In this order, from Toolbox (AJAX section), add
Script Manager, UpdateProgress, then Update Panel.

If you are using Master Pages, and this is a content page, put this under <asp:Content element.


For UpdateProgress, fill out AssociatedUpdatePanelID="UpdatePanel1" DisplayAfter="100".



Add <ContentTemplate> before any Div's.

<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
 
 <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1" DisplayAfter="100">
        <ProgressTemplate>
            <h1 class="red">Please be patient....updating database....</h1>
        </ProgressTemplate>
    </asp:UpdateProgress>


    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>

<div all the stuff on your page></div>

    </ContentTemplate>
</asp:UpdatePanel>