I have a grid view and details view. My details view is in the update panel and it should be displayed for edits of the gridview. I have a file Upload control inside detailsview, Now when I click the upload button the whole page gets refreshed.
What do I do and where do I do? I think it should be some problem with the postback triggers.
use this..
http://geekswithblogs.net/ranganh/archive/2008/04/01/file-upload-in-updatepanel-asp.net-ajax.aspx
set
<Triggers><asp:PostBackTrigger ControlID="your fileupload control id" />
</Triggers>
in update panel
I think , you must post back when uploading a file, but try to do the following:
in the file uploader event : call the following method:
updatepanelName.Update();
If, it should not get refreshed then use the AutoPostBack= false in Upload control.
Related
I have got an update panel in my master page.
in my child page i am trying to upload a file using fileupload control.
page is submitted using a link button called lnkSaveRequest. upon submission page throws a lnkComplete pop up button and think that is preventing my file from being uploaded.
when I try to add both lnkSaveRequest and lnkComplete in triggers
UpdatePanel updatePanel = Page.Master.FindControl("up") as UpdatePanel;
UpdatePanelControlTrigger trigger = new PostBackTrigger();
trigger.ControlID = lnkSaveRequest.UniqueID;
trigger.ControlID = lnkComplete.UniqueID;
updatePanel.Triggers.Add(trigger);
I get the following error
Control with ID 'lnkComplete' being registered through RegisterAsyncPostBackControl or RegisterPostBackControl must implement
either INamingContainer, IPostBackDataHandler, or
IPostBackEventHandler
if I remove the lnkComplete from trigger code , I don't get any error but the file doesnt get uploaded.
Any help much appreciated. or if anyone knows other ways of dealign with update panels in master page please help.
Check remark section in those links, read carefully.
http://msdn.microsoft.com/es-es/library/system.web.ui.postbacktrigger.postbacktrigger(v=vs.110).aspx
'Use the RegisterPostBackControl method of the ScriptManager control to programmatically register a postback control.
http://msdn.microsoft.com/es-es/library/system.web.ui.postbacktrigger%28v=vs.110%29.aspx
Sample postback trigger:
http://msdn.microsoft.com/es-es/library/system.web.ui.postbacktrigger%28v=vs.110%29.aspx
i'm working on a web project. I have a dropdown and i need the selectedvalue for uploading a file using asp:AjaxFileUpload.
Issue: when uploading a file, dropdown values are lost and the selectedvalue will be blank. I don't want to use a Session variable because if I open the same page in two tabs with different dropdown.selectedvalue, the other page might get the wrong session variable. Please help me find another way of getting the dropdown.selectedvalue when uploading a file,
your help will be really appreciated
Try this.
Enclose your DropDownList in an asp UpdatePanel as below:
<asp:UpdatePanel id="someid" runat="server>
<ContentTemplate>
<asp:DropDownList ID="yourdropdownlist" runat="server"></asp:DropDownList>
</ContentTemplate>
</UpdatePanel>
This is because your page is posting back each time.
Set AutoPostBack='false' and use Page.IsPostback property while populating and dealing with drop down box.
MSDN For IsPostBack:
http://msdn.microsoft.com/en-us/library/system.web.ui.page.ispostback.aspx
Hope Its Helpful.
You can use update panel and inside that put your dropdown, file upload control etc..
in your code behind on Page_Load check below condition and bind data.
if (!IsPostBack && !IsCallback && !AjaxFileUpload1.IsInFileUploadPostBack) // Need to prevent normal stuff on ajaxFileUpload PostBack
{
// bind drop down , gridview etc..
}
I have a web page that prompts for user input via DropDownLists in some table cells. When a selection is made the selection replaces the DropDownList so that the action can only be performed once. In the case that a change needs to be made I want to be able to click a button that reloads the page from scratch. I have Googled and Googled but I have not managed to find a way to do this.
Any advice is appreciated.
Regards.
Put a link on the page with the text "Reload" and the url the url of the page. It's perfectly valid to have a page with a link to itself.
If you don't like the link idea, use a standard Button and in the click event, use Response.Redirect to redirect to the current page.
You can set an OnClick for your button that resets each DropDownList's SelectedIndex to 0 instead of reloading the page from scratch. Alternatively, you can set a Response.Redirect([the page's url]) into the OnClick as is suggested here.
I have an Ajax AsyncFileUpload on one of my pages (inside a update panel). The control works, however I want the page to reload after the upload is complete. I tried a Response.Redirect in the code behind for the OnUploadedComplete method and a location.reload(true) in the OnClientUploadComplete. Both result in javascript alert of `Server Response Error: 'Unknown Server error'
Do you want to see the response page?` and the page doesn't refresh.
Has anyone been able to do a full page refresh after the upload has completed?
Edit: I mistakenly said the AsyncFileUpload is in a control panel, I meant to say update panel.
Use asp:FileUpload control and register it as postback control with Scriptmanager's RegisterPostBackControl method. Or add postback trigger entry for this FileUpload to Triggers collection of UpdatePanel
This control panel that you told. Is this a UpdatePanel? If it is, you can try an upd.Update(); to refresh the panel.
Becareful, if you have Response on your backside you may be ending your page's life cycle right there. This is just a guess. Check to make sure that your code is even reaching the intended point. Look for things like Response.End which will will prevent anything thereafter from executing.
I am using Ajax File Upload control in ASP.NET 4 using c#. The same page has an update panel too but the upload control is not inside the update panel. The upload control is outside of the update panel.
The update panel has a captcha image and submit button which is described here too. The submit button inside contains code for saving the file from upload control.
The problem is that when user has browsed the fife to be uploaded using upload control and then enters a wrong captcha value and submits, then a new captcha image is given asynchronously to the user for entry. Now the upload control still shows the path in the upload bar for the file, but on the programming side it does not detects the file.
The submit button code:
if (AsyncFileUpload.HasFile)
{
// upload logic and other stuff
}
else
{
// lblShow.Text = "There is no file to be uploaded";
}
The above code for example executes the else part to say "There is no file to be uploaded". The page still hasn't refreshed totally and the file upload control has the path of the file displayed. Kindly help me with this problem.
If your code:
if (AsyncFileUpload.HasFile)
{
// upload logic and other stuff
}
else
{
// lblShow.Text = "There is no file to be uploaded";
}
is in the Page_Load event, it will still execute in the context of a partial post-back, e.g. the UpdatePanel refresh. If a full form submit has not been performed from the browser (you mentioned your File Upload is outside of the UpdatePanel) then the page will not detect the file upload.
What I am confused about is why you have called it AsyncFileUpload when it is outside the UpdatePanel?
EDIT:
Based on your answer, I don't think your Captcha implementation is workable with async file upload as you have it now.
The UpdatePanel does an async POST to evaluate captcha result, but you will not POST the file contents yet because its not inside the UpdatePanel. Then your server-side code evaluates the captcha result and will either return html or a redirect in the async-response back to the browser... somewhere you need to eventually submit the form to get the file.
Unless you're prepared to write code to send some javascript back to your page in the async-response to trigger a full form submit, AND re-evaluate CAPTCHA again on the form submit, you're probably better off taking out the UpdatePanel, in my opinion.
If you are using Ajax update panel with file upload control then you have to add postback trigger into update panel triggers. Like:
<Triggers>
<asp:PostBackTrigger ControlID="btnContactSubmit"/>
</Triggers>