update panel not working in where upload excel sheet - c#

If i am using update panel then PostedFile not giving file path some error are coming and if update panel are removed the page then excel file successfully upload how to solve

your code should be as shown below
<asp:UpdatePanel runat="server" ID="UpdatePanel1" UpdateMode="Conditional">
<ContentTemplate>
<asp:FileUpload runat="server" ID="flFile" />
<asp:Button runat="server" ID="btnSubmit" Text="Upload" OnClick="btnSubmit_Click" />
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="btnSubmit" />
</Triggers>
</asp:UpdatePanel>
You need to put postback trigger if you are uploading any files.

A FileUpload inside UpdatePanel won't work. You have to post the whole page. You do this by adding a PostBackTrigger to the button you use for uploading files.
Something like this (see Triggers):
<asp:UpdatePanel ID="upnlMain" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:FileUpload ID="fileUpload" runat="server" Width="400px" />
<asp:Button ID="btnUploadFiles" runat="server" Text="Upload files" />
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="btnUploadFiles" />
</Triggers>
</asp:UpdatePanel>
If you have problems with not posting the first time a button is clicked then add this to Page Load event:
Page.Form.Attributes.Add("enctype", "multipart/form-data");

Related

FileUpload.hasFile returning false inside update panel

I have been through several links but didn't find anything helpful. I know it has been asked several times here.
Here is my frontend code
<asp:UpdatePanel runat="server" ID="UpdatePanel1" UpdateMode="Conditional">
<ContentTemplate>
<asp:FileUpload runat="server" ID="fuItemImage" Width="370px" TabIndex="12" />
</ContentTemplate>
<Triggers>
</Triggers>
</asp:UpdatePanel>
Here is the backend code
if (fuItemImage.HasFile)
{
MyFunction.UploadThisFile(anything)
}
When I upload any image and click on the save button it shows false in FileUpload.HasFile. I am stuck and finding no solution for it.
Any help would be appreciated.
you can try this
<asp:ScriptManager runat="server"></asp:ScriptManager>
<asp:UpdatePanel runat="server" ID="UpdatePanel1" UpdateMode="Conditional">
<ContentTemplate>
<asp:FileUpload runat="server" ID="fuItemImage" Width="370px" TabIndex="12" />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID = "Button1" />
</Triggers>
</asp:UpdatePanel>
add the button id in triggers to upload the file which will do postback

reload on button click in

Here is my aspx:
<asp:Panel ID="pnl_updateClinicVisit" runat="server" CssClass="modalPopupClinicVisitEntry2" DefaultButton="bt_editClinicVisit_submit" Style="display:none">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button AutoPostBack="false" UseSubmitBehavior="false" ID="AddMedicationChange" ClientIdMode="Static" runat="server" Text="Add Med Change" OnClick="AddMedicationChange_Click" />
<asp:Panel ID="AddNewMedicationPanel" runat="server">
<asp:TextBox ID="NewDrugName" OnTextChanged="NewDrugName_TextChanged" runat="server"></asp:TextBox>
<asp:AutoCompleteExtender ID="NewDrugNameAutoCompleteExtender"
runat="server"
TargetControlID="NewDrugName"
MinimumPrefixLength="1"
EnableCaching="false"
CompletionSetCount="1"
CompletionInterval="500"
ServiceMethod="GetDrugs">
</asp:AutoCompleteExtender>
<asp:DropDownList OnSelectedIndexChanged="NewDrugChange_SelectedIndexChanged" ID="NewDrugChange" runat="server">
<asp:ListItem>Drug +</asp:ListItem>
<asp:ListItem>Drug -</asp:ListItem>
<asp:ListItem>Dose ↑</asp:ListItem>
<asp:ListItem>Dose ↓</asp:ListItem>
</asp:DropDownList>
<asp:Button AutoPostBack="false" UseSubmitBehavior="false" ID="SubmitMedChange" runat="server" Text="Add to Visit" OnClick="SubmitMedicationChange_Click" />
</asp:Panel>
<asp:ModalPopupExtender ID="updateClinicModalPopupExtender" runat="server" TargetControlID="bt_editClinicVisit_dummy"
PopupControlID="pnl_updateClinicVisit" CancelControlID="bt_editClinicVisit_cancel"
DropShadow="true" BackgroundCssClass="modalBackground" />
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
For some reason my page is reloading when I click the "AddnewMdication" and "SubmitMedChange" buttons. When I have the AutoPostBack=false UseSubmitBehavior=false, the events fire and then the page reloads. If I don't have these attributes then the page reloads before the events even fire. How do I get AJAX functionality within this modal?
Try setting your Buttons as an AsyncPostBackTrigger. You can do this by adding in the Triggers section and declaring the UpdatePanel as a conditional update.
For example
<asp:UpdatePanel ID="UpdatePanel1" runat="server"
UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="AddMedicationChange" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="SubmitMedChange" EventName="Click" />
</Triggers>
<ContentTemplate>
<%-- Your code here --%>
</ContentTemplate>
</asp:UpdatePanel>
What this should do is to explicitly declare that those two buttons as being Async.
If this doesn't work, will you please post the relevant code to your two button OnClick events? AddMedicationChange_Click and SubmitMedicationChange_Click
If you try to interact with controls outside of the UpdatePanel in your code-behind during an asyncpostback, odd things can start to happen.

How to active AsyncPostBackTrigger in Update Panel?

I created a updatePanel, is include some dropdownlist and a few button and I use AsyncPostBackTrigger for not update all page when the click button or select dropdownlist.
My page structure that an aspx page and also use user control page. I use updatePanel on UserControlPage.
Here is My code and I wish you help me:
<asp:UpdatePanel ID="UpdMonthly" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:DropDownList ID="ddlSenetIslemleriAlinanUrun1" AutoPostBack="true" OnSelectedIndexChanged="ddlSenetIslemleriAlinanUrun1_SelectedIndexChanged" runat="server"></asp:DropDownList>
<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
<asp:Button ID="btnKaydet" style="margin:10px ;" Width="100" Height="50" runat="server" Text="Kaydet" OnClick="btnKaydet_Click"/>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlSenetIslemleriAlinanUrun1" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="btnKaydet" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
I have some knowledge on placeholder but when the click dropdown or button, page is postback and placeholder knowledge dissappear.
how to fix postback problem?
Thanks for your answers.

Page stalls when a asynchronous request is processing in UpdatePanel

I have two UpdatePanel in a single asp.net page.One has a submit button and a progress bar , on click on this button there is a process which fetch the data from a XML file and stores in Database.
Second update panel is used to display the content from a log about the progress of the data insertion from XML and it is updated using a timer control.
Now the problem is that when a request is submitted from first panel , second panel stop updating the content.
Should I try any other library or some sort of jq metohods to update page.
thanx in advance
here is my code,...
<asp:scriptmanager runat="server" ID="scrpManager"> </asp:scriptmanager>
<asp:UpdatePanel ID="updLeft" runat ="server">
<ContentTemplate>
<asp:Button ID="Submit" runat="server" onclick="Submit_Click"
Text="Process" />
</ContentTemplate>
<Triggers >
<asp:AsyncPostBackTrigger ControlID ="Button3" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<asp:UpdateProgress runat="server" AssociatedUpdatePanelID="updLeft"
ID="UpdateProgress21">
<ProgressTemplate>
<div class="loadingbox">
<img src="spinner.gif" align="absmiddle" />
<asp:Label ID="lblProgress21" runat="server">Please wait while processing...</asp:Label>
</div>
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="updPnlRight" runat ="server" >
<ContentTemplate >
<asp:Timer Interval="1000" ID="timer1" runat="server" ontick="timer1_Tick" ></asp:Timer>
<asp:GridView ID="GridView1" ShowHeader ="false" AutoGenerateColumns ="false" runat="server">
<Columns >
<asp:BoundField DataField ="status_MSG" HeaderText ="" />
</Columns>
</asp:GridView>
</ContentTemplate>
<Triggers >
<ajax:AsyncPostBackTrigger ControlID ="timer1" EventName="Tick" />
</Triggers>
</ajax:UpdatePanel>
protected void Submit_Click(object sender, EventArgs e)
{
//Do insertion process , takes 30 minutes,
}
I've had nothing but misery with update panels. I urge you to use an alternative such as client side templates. Knockout.js and Angular.js are probably good places to start.
If you paste your code, or a (non) working example of your issue, I'll try offer a fix.

asyncfileupload inside update panel not triggering the upload method

I am having a asyncfileupload inside a update panel, I want to upload the file once when a file is selected , the same code works well outside the update panel but my design is in such a way that I can put this outside the update panel, how can I make this work
<asp:UpdatePanel ID="UP_DDL" runat="server" UpdateMode="Always" Visible="true"
RenderMode="Inline">
<ContentTemplate>
<asp:asyncfileupload id="AFU_Doc" runat="server"
uploadingbackcolor="Yellow" onuploadedcomplete="btnDocUpload_Click"
onclientuploadcomplete="sa" throbberid="spanUploading2" />
<span id="spanUploading2" runat="server">Uploading...</span>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="AFU_Doc" />
</Triggers>
</asp:UpdatePanel>

Categories