aspx FileUpload empty when used with UpdateProgress indicator - asp.net

The FileUpload and Button controls work fine by themselves. When I add the rest of the code as seen below for the UpdateProgress indicator, the FileUpload control is empty (PostedFiles.Count = 0) after selecting files and btnUpload. 'Loading...' displays ok. Something seems to reset FileUpload. Any ideas?
<asp:FileUpload ID="fuImageUploader" runat="server" AllowMultiple="True" BorderStyle="Inset" BorderWidth="1px" Font-Size="Larger" Height="24px" oninput="fuImageUploader_Click()" ToolTip="Select image file" ValidateRequestMode="Disabled" Width="391px" />
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel runat="server" id="UpdatePanel1">
<ContentTemplate>
<asp:Button ID="btnUpload" runat="server" Height="26px" Text="Upload" Width="86px" OnClick="btnUpload_Click" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress runat="server" id="PageUpdateProgress" AssociatedUpdatePanelID="UpdatePanel1">
<ProgressTemplate>
Loading...
</ProgressTemplate>
</asp:UpdateProgress>

Related

Button click event not firing in case of update panel, AsyncPostBackTrigger also defined

I am fetching data from DB and assign it to repeater.
When I click on button event it only goes to page load function but not to the required on-click event.
I am confused as to why this is happening.
And when I comment out repeater its working fine. I don't why it's not working with repeater in page load.
Aspx code:
<form runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel runat="server" pdateMode="Conditional" ChildrenAsTriggers="true" >
<asp:Button ID="Button2" runat="server" Text="Next Availabilities"
OnClick="Button2_Click" />
<asp:Repeater id="repeater1" runat="server">
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text=""><%# Eval("Time") %></asp:Label>
</ItemTemplate>
</asp:Repeater>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID ="Button3" EventName ="Click" />
<asp:AsyncPostBackTrigger ControlID ="Button2" EventName ="Click" />
</Triggers>
</asp:UpdatePanel>
</form>
In your UpdatePanel:
Correct pdateMode to UpdateMode
Remove ChildrenAsTriggers="true"
Add starting tag of <ContentTemplate>
Assign id ID="UpdatePanel1"
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>

Ajax UpdatePanel not working?

I am very new to Ajax and have been impressed with reading about it and how you can refresh a area of a page and not the whole thing. I thought doing this when reading about it was fairly easy but I'm abit stuck on an area.
I have a Report-viewer on my page which uses a ScriptManager and I have a calendar control which when I click a day will need to refresh to put that into a Textbox.
The Report-viewer is on the page when it loads it needs to be passed a parameter but can only get that after they have selected something from a combobox
So this is what I have done so far:
<li>
<asp:UpdatePanel runat="server" ID="updateDOI">
<ContentTemplate>
<input id="txt_DateOfInterview" type="Date" class="aclass" runat="server" />
<asp:ImageButton runat="server" ImageUrl="~/Images/Calender.png" ID="calendericonDOI" CssClass="calendericonDOI ClanderDOI" OnClick="calendericonDOI_Click"></asp:ImageButton>
<asp:Calendar runat="server" ID="ClanderDOI" CssClass="ClanderDOI" OnSelectionChanged="ClanderDOI_SelectionChanged" BorderColor="#6a3d98" OnVisibleMonthChanged="ClanderDOI_VisibleMonthChanged">
<TitleStyle BackColor="Orange" />
</asp:Calendar>
</ContentTemplate>
</asp:UpdatePanel>
As you can see i have a wrapped a UpdatePanel around the calender and also the input box that will get populated with the day selected
And then with the report viewer I have done the same:
<asp:UpdatePanel runat="server" ID="UpdatePanel1">
<ContentTemplate>
<rsweb:ReportViewer ID="rvSickness" runat="server" BackColor="#6e4594" Font-Names="Arial" Font-Size="8pt" Height="100%" ProcessingMode="Remote" WaitMessageFont-Names="Arial" WaitMessageFont-Size="14pt" Width="450px" ShowCredentialPrompts="False" ShowParameterPrompts="False" ShowPromptAreaButton="True" ShowToolBar="true" ShowFindControls="False" ToolBarItemBorderColor="#FF9900" ToolBarItemHoverBackColor="#FF9900" ForeColor="White">
<ServerReport ReportServerUrl="" />
</rsweb:ReportViewer>
</ContentTemplate>
</asp:UpdatePanel>
But what I don't understand it that the ReportViewer is still refreshing when I do anything.
My question is why is the Report-viewer refreshing when I am selecting something from a calender control? Is it because it has not been passed a parameter yet or have I done something wrong?
what you can do is take two update panels
In first UpdatePanel in which i took a DropDownList(here i took some sample dropdown list items)
<asp:UpdatePanel runat="server" ID="UpdatePanel1" UpdateMode="Conditional">
<ContentTemplate>
<asp:DropDownList ID="DropDownList1" ClientIDMode="AutoID" runat="server" AutoPostBack="true" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem>one</asp:ListItem>
<asp:ListItem>two</asp:ListItem>
<asp:ListItem>three</asp:ListItem>
<asp:ListItem>four</asp:ListItem>
</asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
Second update panel in which i took your ReportViewer
<asp:UpdatePanel runat="server" ID="UpdatePanel2" UpdateMode="Conditional">
<ContentTemplate>
<rsweb:ReportViewer ID="rvSickness" runat="server" BackColor="#6e4594" Font-Names="Arial" Font-Size="8pt" Height="100%" ProcessingMode="Remote" WaitMessageFont-Names="Arial" WaitMessageFont-Size="14pt" Width="450px" ShowCredentialPrompts="False" ShowParameterPrompts="False" ShowPromptAreaButton="True" ShowToolBar="true" ShowFindControls="False" ToolBarItemBorderColor="#FF9900" ToolBarItemHoverBackColor="#FF9900" ForeColor="White">
<ServerReport ReportServerUrl="" />
</rsweb:ReportViewer>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="DropDownList1" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
Now in code behind you can pass the id to your ReportViewer on DropDownList1_SelectedIndexChanged event like this
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
//your code here
}
Note: I didn't took you calendar and other controls in this answer as you wanted to update the ReportViewer only when you select an item from DropDownList

Submit button doesn't work on enter in IE aspp.net

<asp:Button ID="newbutton" runat="server" Text="Click" onsubmit="button_click" OnClick="button_click" />
I have this button in update panel and i want it to work on enter not only onclick it works in google chrome , but not in ie what should I do?
On the panel set the default button to the id of the button
<asp:Panel runat="server" id="examplePanel" DefaultButton="newbutton">
Set the default button for update panel with the Id of this button
Sample:
<asp:UpdatePanel ID="upTest" runat="server">
<ContentTemplate>
<asp:Panel runat="server" ID="pTest" DefaultButton="newbutton">
<asp:Button ID="newbutton" runat="server" Text="Click" onsubmit="button_click" OnClick="button_click" />
ASP:Button cannot work with enter because it has OnClick. To react on enter properly you should use ASP:Panel with DefaultButton property. You need to have focus on control inside asp:Panel for example TextBox
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Panel ID="Panel1" runat="server" DefaultButton="newbutton">
<asp:TextBox ID="TxtUserLogin" runat="server" TabIndex="1" Text="login" />
<asp:Button ID="newbutton" runat="server" Text="Click" OnClick="button_click" />
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>

Why can I not unregister my UpdatePanel when it was not registered with the ScriptManager?

I am using the modal pop up in the code below. I am getting the following error:
Cannot unregister UpdatePanel with ID 'updatePnl' since it was not registered with the ScriptManager. This might occur if the UpdatePanel was removed from the control tree and later added again, which is not supported.
Parameter name: updatePanel
What could be causing this?
Here is my code:
<telerik:GridTemplateColumn HeaderStyle-Width="20%" HeaderText="See Your Assessment">
<ItemTemplate>
<asp:Button CommandName="Show" OnClick="grdMasterbtnClick" CommandArgument='<%#Eval("SurveyClientID")%>'
ID="btn" runat="server" Text="Your Assessment" />
<cc1:ModalPopupExtender CancelControlID="btnCancel" PopupControlID="modelPopUp" ID="ModalPopupExtender1"
runat="server" TargetControlID="imgClientFreeEval">
</cc1:ModalPopupExtender>
<asp:UpdatePanel ID="updatePnl" runat="server">
<ContentTemplate>
<asp:Panel ID="modelPopUp" runat="server" Visible="false" BackColor="AliceBlue">
<p>
These items will be permanently deleted and cannot be recovered. Are you sure?
</p>
<asp:Button ID="btnOk" Text="OK" runat="server" />
<asp:Button ID="btnCancel" Text="Cancel" runat="server" />
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</ItemTemplate>
<HeaderStyle Width="20%"></HeaderStyle>
</telerik:GridTemplateColumn>

<asp:FileUpload with UpdatePanel

Im trying tp upload more than one image, and when each one I upload I will show it in a repeater, but in the code behind the FileUpload1.HasFile is always False , this is a piece of my code :
<asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional" >
<ContentTemplate>
<asp:Repeater ID="rpUploadedImages" runat="server">
<ItemTemplate>
<img src='../Images/<%# DataBinder.Eval(Container.DataItem, "ImagePath")%>'/><br />
</ItemTemplate>
</asp:Repeater>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnupload" EventName="click" />
</Triggers>
</asp:UpdatePanel>
<asp:FileUpload ID="FileUpload1" runat="server" /><br />
<asp:Button ID="btnupload" runat="server" Text="Upload" onclick="btnupload_Click" />
The FileUpload control does not work with UpdatePanel, you will need to do a full post back to get the file on the server... Now there are a lot of tricks to make it ajaxy...
http://geekswithblogs.net/ranganh/archive/2008/04/01/file-upload-in-updatepanel-asp.net-ajax.aspx
Another tricky way is to create iframe with fileupload + submit button(or some trigger) inside your main form. iframe will postback with no effect to main page.

Resources