A User control with FileUpload not working

Last post 07-08-2009 3:36 AM by Thomas Sun – MSFT. 2 replies.

Sort Posts:

  • A User control with FileUpload not working

    07-05-2009, 8:14 PM
    • Member
      10 point Member
    • rbadis
    • Member since 04-23-2007, 7:44 AM
    • Posts 339

    Hi,

    I've created a web user control that have a FileUpload and a Button, and did put this control inside an UpdatePanel then register it like : 

    ScriptManager.RegisterPostBackControl(Document1)

    and it worked OK. But the problem is that if I put another instance of my control and register them like:

    ScriptManager.RegisterPostBackControl(Document1)

    ScriptManager.RegisterPostBackControl(Document2)

    The second instance (Document2) works fine but Not the first one (Document1) and for that I'm assuming that only the second Document did get registered.

    I've tried this solution in the folowing link and it didn't work:

    http://disturbedbuddha.wordpress.com/2007/12/12/handling-multiple-asynchronous-postbacks/

    So, how can register more then one control?

     

    Thanks

    badis
  • Re: A User control with FileUpload not working

    07-06-2009, 12:50 AM
    Answer
    • Member
      561 point Member
    • harieis
    • Member since 04-23-2009, 12:11 PM
    • Trivandrum
    • Posts 150

    Please add this code ur application.

     <asp:UpdatePanel ID="updtOverDueTasks" runat="server">
    <Triggers >
    <asp:AsyncPostBackTrigger ControlID="YourFileUploader_ name" />
    </Triggers>
        <ContentTemplate>

    ...................................

    ................

    Please, Mark as Answer if this reply helped you
    ==============================================

    Harikrishnan.S
    Trivandrum,Technopark,
    Kerala,
    India
    harikrishnans82@gmail.com
    ==================================================
  • Re: A User control with FileUpload not working

    07-08-2009, 3:36 AM
    Answer

     Hi,

    We can register more controls which exist in Updatepanel to trigger for a full postback by using ScriptManager.RegisterPostBackControl Method (http://msdn.microsoft.com/en-us/library/system.web.ui.scriptmanager.registerpostbackcontrol.aspx).

    For example, there are three buttons in Updatepanel and we will register two of them to fire full post back:

    <%@ Page Language="C#" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <script runat="server">
    
        protected void Page_Load(object sender, EventArgs e)
        {
            Label1.Text = "Label inside Updatepanel " + DateTime.Now.ToString();
            Label2.Text = "Label outside Updatepanel " + DateTime.Now.ToString();
    
            ScriptManager1.RegisterPostBackControl(Button1);
            ScriptManager1.RegisterPostBackControl(Button2);
        }
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:scriptmanager ID="ScriptManager1" runat="server">
            </asp:scriptmanager>
        
        </div>
            <asp:updatepanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
                <contenttemplate>
                    <asp:label ID="Label1" runat="server" Text="Label"></asp:label>
                    <asp:button ID="Button1" runat="server" Text="Button1 is registered" />
                    <asp:button ID="Button2" runat="server" Text="Button2 is registered" />
                    <asp:button ID="Button3" runat="server" Text="Button3 is NOT registered" />
                </contenttemplate>
            </asp:updatepanel>
            <asp:label ID="Label2" runat="server" Text="Label"></asp:label>
        </form>
    </body>
    </html>

    If you want to set trigger for Updatepanel, please see http://www.asp.net/AJAX/Documentation/Live/mref/P_System_Web_UI_UpdatePanel_Triggers.aspx

     

    I look forward to receiving your test results.

    Thomas Sun
    Microsoft Online Community Support

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question.
Page 1 of 1 (3 items)