Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Craig Cronin 304 posts 503 karma points
    Oct 20, 2010 @ 00:22
    Craig Cronin
    0

    Hooking save event in PostbackTrigger

    I can't find this anywhere and really struggling. 

    I have create a custom section which allows users to add an image and the code is below.  Instead of having an upload button I would like to hook into the form save so that when a user saves the form then it uploads and refreshes the image on the screen.

    This does seem quite tough!  Any help would be appreciated.  Thanks

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    <

     

     

     

    umb:PropertyPanel ID="PPanel3" runat="server" Text="Image Location">

     

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

    <Triggers>

     

    <asp:PostBackTrigger ControlID="btnUpload" />

     

     

    </Triggers>

     

    <ContentTemplate>

     

    <asp:Image ID="imgAdvert" runat="server" />

     

    <br />

     

    <asp:FileUpload ID="myFile" runat="server" />

     

    <br />

     

    <asp:Label ID="lblMsg" runat="server"></asp:Label>

     

     

    <br />

     

    <asp:Button ID="btnUpload" runat="server" Text="Upload"

     

     

    OnClick="UploadFile" OnClientClick="javascript:showWait();"/>

     

     

    <asp:UpdateProgress ID="UpdateProgress1" runat="server"

     

     

    AssociatedUpdatePanelID

    ="UpdatePanel1">

     

    <ProgressTemplate

    >

     

    <asp:Label ID="lblWait" runat="server" BackColor="#507CD1"

     

     

    Font-Bold="True" ForeColor="White"

     

     

    Text="Please wait ... Uploading file"></asp:Label

    >

     

    </ProgressTemplate

    >

     

    </asp:UpdateProgress

    >

     

    </ContentTemplate

    >

     

    </asp:UpdatePanel

    >

     

    </umb:PropertyPanel

    >

  • chappers 18 posts 36 karma points
    Oct 27, 2010 @ 01:51
    chappers
    0

    When you say "form save" do you mean have a standard save icon for your custom sections page and have a click event to handle upload etc?

    You will need a TabView to add the save button to in your sections page.

    Add like this:

    First you will need to register <%@ Register Namespace="umbraco.uicontrols" Assembly="controls" TagPrefix="umb" %>

    Then add...

    <umb:TabView runat="server" ID="tabControl" Width="552px" Height="692px" />

    Group your various controls into logical panes e.g.

    <umb:Pane ID="pnePublished" runat="server" Height="600px" Width="330px">
                    <umb:PropertyPanel runat="server" Text="Show on site" ID="PropertyPanel10">                   
                        <asp:CheckBox ID="chkPublished" runat="server" />
                    </umb:PropertyPanel> 
    </umb:Pane>

    This allows you to created tab interface and add panes content to various tabs.

    In code behind add a  "protected override void OnInit(EventArgs e)"

    Here you add your tabs and panes to the tab control like:

    DetailsTab = tabControl.NewTabPage("Details");

    DetailsTab.Controls.Add(pnePublished);

    Next the bit you are probably most interested in - hooking up a save button

    Still in the OnInit add something like

    ImageButton save = DetailsTab.Menu.NewImageButton();
    save.Click += new ImageClickEventHandler(this.save_click);
    save.AlternateText = "Save";
    save.ImageUrl = GlobalSettings.Path + "/images/editor/save.gif";

    Then just add 

    private void save_click(object sender, System.Web.UI.ImageClickEventArgs e)
     {

    // Do whatever processing here....

    }

     

    That should do the trick!

    Extra tip if you want the fancy speech bubble messages you can use:

    ((BasePage)Page).ClientTools.ShowSpeechBubble(BasePage.speechBubbleIcon.save, "Saved", "Mess here...");

     

    Hope that helps

Please Sign in or register to post replies

Write your reply to:

Draft