 |
|
 |
THANKS! That did it for me in a situation with nested master pages surrounding the update panel! I was almost going nuts!
|
|
|
|
 |
|
 |
hello , it still do postback , how to upload without refresh all the page ?? thanks alot in advance.
|
|
|
|
 |
|
 |
THis article is about getting file upload to work in an MS ajax update panel. I don't know how to do an ajax upload. Maybe jquery can help?
Liam McLennan
liam@eclipsewebsolutions.com.au
www.eclipsewebsolutions.com.au
|
|
|
|
 |
|
|
 |
|
 |
The point here is that the FileUpload control itself will not function inside an Ajax panel without causing a full page postback. Therefore, AJAX does not apply to the File Upload control itself. It's for the other controls on the page.
Further reading, however, reveals that this is a limitation of javascript moreso than a limitation of .NET. According to ajaxf1.com[^], it's a security limitation. They recommend the "iframe" strategy (include an iframe of the upload target), which does work. Personally, I try to steer away from iframe's when possible.
|
|
|
|
 |
|
|
 |
|
 |
Hi Frnds,
I am facing some update panel problems while using a treeview control.
1) I set the expandDepth=1, and when the inner node is clicked entire tree is getting collapsed.
2) Giving PopulateOnDemand can not be set to true when then node is already set populateOnDemand to true. (This is becoz the child items r getting populated dynamically at runtime on click of node).
3) I have a download button in update panel when i clicked it, the exception Message is
"Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.
Details: Error parsing near 'Fixes in PL/SQL Deve'."
Generally v use Response.WriteFile or TransmitFile while downloading a file, The exception is here only..
Is there any property of update panel to be set to keep working with treeview or the update panel w'll not supported for treeview control?
And also any alternative for downloading the file from within updatepanel?
All the suggessions and solutions are appreciated and valueable to me.
Thands in advance.
Regards
Hasan.
|
|
|
|
 |
|
 |
Liam McLennan's excellent article on how to set a postback trigger for the fileupload control in the update panel works great, unless the file upload control happens to be inside a user control that is inside of the update panel. There is no way to set the trigger to the control in the ascx file!
Any ideas?
|
|
|
|
 |
|
 |
When specifying the control id for the postback trigger use the following syntax usercontrolname:fileuploadcontrolname
Liam McLennan
liam@eclipsewebsolutions.com.au
www.eclipsewebsolutions.com.au
|
|
|
|
 |
|
 |
Hmm i like it, but it did not work. Now, the 'usercontrol name' I think is 'Utils1' the ascx control istself is called Utils.ascx, and i make reference to it as such as Utils1 in other code behind like that. Here is the reference:
<%@ Register Src="Utils.ascx" TagName="Utils" TagPrefix="uc3" %>
I tried 'Utils', Utils1' and 'uc3' they all give the same thing.
A control with ID 'Utils1:FileUpload1' could not be found for the trigger in UpdatePanel 'UpdatePanel1'.
|
|
|
|
 |
|
 |
To assign the postback trigger from within a user control, you can use the code-behind to reference the parent page and make the trigger. Here's how:
On your parent page, you have the following code somewhere in the page which includes your scriptmanager, updatepanel, and user control that has a file upload in it:
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<MyUserControls:MyControl id="usrMyUploadControl" runat="server" ScriptManagerName="ScriptManager1" />
<!---->
</ContentTemplate>
</asp:UpdatePanel>
Now, in your user control, you will have the following code which will search for the ScriptManager in the page's collection of nested controls. Then it will register the postback trigger from within your user control. This is how we can reference the user control's upload button, which in this case is called btnUpload.
public string ScriptManagerName = "";
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
if (ScriptManagerName.Length > 0)
{
ScriptManager scriptManager = (ScriptManager)SearchControl(Page, ScriptManagerName);
if (scriptManager != null)
{
scriptManager.RegisterPostBackControl(btnUpload);
}
}
}
public Control SearchControl(Control container, string id)
{
Control control = container.FindControl(id);
if (control == null)
{
foreach (Control c in container.Controls)
{
if (c.HasControls())
{
control = SearchControl(c, id);
if (control != null) break;
}
}
}
return control;
}
|
|
|
|
 |
|
 |
Guys,
Another thing to remember, is that if the upload control is not visible on load, the enctype of the form will never be set to 'multipart/form-data' without which this all will not work.
So in the control, in which ever event handler reveals the upload control:
ScriptManager SM = (ScriptManager)Page.Master.FindControl("uxScriptManager");
SM.RegisterPostBackControl(btnAddIssue);
And in the parent page, or where ever the form is defined:
if (!this.IsPostBack)
{
this.Page.Form.Enctype = "multipart/form-data";
}
Happy coding!
Aikiken
|
|
|
|
 |
|
 |
Hi
Great work guys! This and SearchControl solved my problem off dynamically generated user control in master/content/usercontrol site. Thank you alot!
aikipoodle wrote: if (!this.IsPostBack) { this.Page.Form.Enctype = "multipart/form-data"; }
/Liam Rr.
|
|
|
|
 |
|
 |
Been looking for a solution to this problem for AGES... Thanx
|
|
|
|
 |
|
 |
I am trying to accomplish this without a button.
Everything I see has the FileUpload control.
|
|
|
|
 |
|
 |
You need to trigger a postback, but you don't need a button to do this. I don't know how to do it without a FileUpload control (or the equivalent html control).
Liam McLennan
liam@eclipsewebsolutions.com.au
www.eclipsewebsolutions.com.au
|
|
|
|
 |
|
|
 |
|
 |
I've tried to add a postback trigger to my updatepanel, but get the following message. Async triggers don't give the message, but then they don't make the fileupload control work, either. I see from other posts here that people have been able to make this work. What do you suppose I'm doing wrong? By the way, asp seems to be adding the code at line 301. I search the source and don't find it, but it is in the processed page. - Jeremy Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. Parser Error Message: Only Content controls are allowed directly in a content page that contains Content controls. Source Error:
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. Parser Error Message: Only Content controls are allowed directly in a content page that contains Content controls. Source Error:
<!--Line 299: </asp:UpdatePanel> --> [commented so it will show up- jeremy] <!--Line 300:</asp:Content> --> Line 301: <triggers></triggers>
|
|
|
|
 |
|
 |
Thanks for the tip and it has saved my time when I started to stuggle with this issue. Thanks to postbacktrigger too.
|
|
|
|
 |
|
 |
Didn't know there was a limitation on using the upload control within an update panel... Now I do and know how to work around it. Looks like the some of the other comments are people who just don't get this.
Aaron Barker
www.tapconsulting.com
|
|
|
|
 |
|
 |
When u use
<%-- asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" --%>
that time shows updateprogress bar but file name is not accesible in button click event
and when u use
<%-- asp:PostBackTrigger ControlID="Button1" --%>
that time file name is accesible but not shows progress bar
Then how can i access the filename with showing the progress bar?
Plz help me
shan
-- modified at 3:04 Monday 1st October, 2007
|
|
|
|
 |
|
 |
shan,
you cannot do that. ASP.NET AJAX is just a layer on top of the javascript and javascript doesn't allow you to access the client's file.
some people use WebService to send binary packages via SOAP protocol, some people use IFRAME technique.
you need to considering your option.
supernont
((-supernont-))
|
|
|
|
 |
|
 |
Here's a more reliable way to ensure that the control you want is found by the script manager and the trigger:
Override your OnPreRender for the page like this:
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
ScriptManager1.RegisterPostBackControl(m_btnSaveLogo);
//
//--If your ScriptManager is in a master page, use the following instead:
//
//ScriptManager sm = Master.FindControl("ScriptManager1") as ScriptManager;
//sm.RegisterPostBackControl(m_btnSaveLogo);
}
This method works much better than the "Triggers" tag, because your code will always find the control no matter where it is inside any naming-container type control.
Bruce Pierson
|
|
|
|
 |
|
 |
Thanks Bruce... Worked like a Charm
Mike Kushner
|
|
|
|
 |
|
 |
hi,
how do i use the trigger if my button is inside a Formview's edit mode?
currently just referencing the button won't work as the control can't be found
|
|
|
|
 |