 |
|
 |
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
|
|
|
|
 |
|
 |
Use this syntax:
formviewname:buttonname
|
|
|
|
 |
|
 |
tried it..but i got an
A control with ID 'FormView1:Update' could not be found for the trigger in UpdatePanel 'updatepanel1'.
|
|
|
|
 |
|
 |
I have the same exact error for my DetailsView control.
A control with ID 'dtvAuthor:btnUpdate' could not be found for the trigger in UpdatePanel 'UpdatePanel_main'
Any help is greatly appreciated.
|
|
|
|
 |
|
 |
Did anyone ever find a solution to this w/o using iframes? I sure would like to know.
Anyone remember the PDP11?
|
|
|
|
 |
|
 |
I am a newbie to Dot Net and I am developing a web application using a Wizard control. I have 8 steps on this wizard, steps 3,4,5,6 has a file upload control on each of these steps.
The HasFile returns false for the file upload control on the 3rd step of the wizard.
If I place the File upload control on the final step, it returns true.
I dont know where to place this trigger inside the source page.
I tried placing it after the Wizard control before wizard step and I get an error.
Appreciate your help.
Regards.
|
|
|
|
 |
|
 |
Hi,
If you are not using AJAX then you do not need triggers. If you are using UpdatePanels then the element goes inside the .
|
|
|
|
 |
|
 |
Thanks Bob. I have an AJAX enabled website. I used this as I wanted to use the Calendar Control and in the future will be using accordian control.
If I dont need triggers, then how can I make the Finsih Button recognize the file attached in steps 3,4,5,6?
Because my final step is to upload these files on the file server and store the location info in the database.
|
|
|
|
 |
|
 |
Each time the user leaves a wizard page that has a fileupload you will need to check FileUpload.HasFile and save the file. You will need to ensure that a postback occurs when moving between pages of the wizard, otherwise the files will not upload. I expect that you will have to create a postback trigger for the wizard control itself.
|
|
|
|
 |
|
 |
When i click on upload button first time,it doesn't fire click event.Then after it's working fine. what' wrong woth it. please tell me as soon as possible which version of ajax used in example ?
-- modified at 9:30 Friday 18th May, 2007
|
|
|
|
 |