Thank you bruce,
I am trying to implement an upload progress indicator using atlas, using the following workaround:
http://forums.asp.net/thread/1321664.aspx
This is the code in FileUpload.apsx file is as follows:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title> drag </title>
</head>
<body>
<form id="f1" enctype="multipart/form-data" runat="server">
<h4>Select a file to upload:</h4>
<atlas:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" />
<atlas:UpdatePanel ID="upResults" runat="server" Mode="conditional">
<Triggers>
<atlas:ControlEventTrigger ControlID="Upload" EventName="Click" />
</Triggers>
<ContentTemplate>
<asp:FileUpload id="FileUpload" runat="server"> </asp:FileUpload>
<asp:Button id="Upload" Text="Upload file" runat="server"> </asp:Button>
</ContentTemplate>
</atlas:UpdatePanel>
<asp:Button id="Button1" OnClick="UploadButton_Click" runat="server"></asp:Button>
<br /><br />
<atlas:UpdateProgress ID="uprProgress" runat="server">
<ProgressTemplate>
<img src="images/animated_loading.gif" /> Uploading....
</ProgressTemplate>
</atlas:UpdateProgress>
</form>
</body>
</html>
The relevant code from the code behind file is:
protected void Page_Load(object sender, EventArgs e)
{
( * ) Upload.Attributes.Add("onClick", "__doPostBack('" + Button1.ClientID + "','');return false;");
ClientScript.GetPostBackEventReference(Button1, "");
}
protected void UploadButton_Click(object sender, EventArgs e)
{
String savePath = @"C:\Temp\uploads\";
if (this.FileUpload.HasFile)
{
String fileName = FileUpload.FileName;
savePath += fileName;
FileUpload.SaveAs(savePath);
}
else
{
}
}
The problem is, in the line of code in the Page_Load Function, if I use the "onClick" the (ProgressTemplate is not displayed), if I use the "onClientClick" the ProgressTemplate is correctly displayed but the file is not uploaded.
Any idea what might be wrong?
Many thanks,
Marko
"bruce barker (sqlwork.com)" <b_*************************@sqlwork.com> wrote in message news:%2****************@TK2MSFTNGP02.phx.gbl...
you have several errors
1) spelled "__doPostback" wrong
2) left quotes off the parameter value
3) passed the type name rather than the client id
4) did not cancel the original postback, so when fixed will postback twice.
5) "__doPostback" is only defined if an autoback control is on the page.
try:
Upload.Attributes.Add("onClick", "__doPostback("' + Button1.ClientID + '",'');return false");
GetPostbackClientEvent( Button1,"");
-- bruce (sqlwork.com)
"Marko Vuksanovic" <ma*************@hotmail.com> wrote in message news:D3**********************************@microsof t.com...
I am trying to cause the uplaod button, id="Upload",when clicked, to exectue the onClick event for Button1, id="Button1".
<asp:FileUpload id="FileUpload" runat="server"> </asp:FileUpload>
<asp:Button id="Upload" Text="Upload file" runat="server"> </asp:Button>
<asp:Button id="Button1" OnClick="UploadButton_Click" runat="server" Visible="false">
in the code behind file I am using the following code to add the __doPostBack to the Upload button:
protected void Page_Load(object sender, EventArgs e)
{
Upload.Attributes.Add("onClick", "__doPosback(" + Button1.ToString() + ",'')");
}
When I run this in IE the javascript throws the error:
'System' is undefined.
When I use the source view, the line which causes the error is as follows:
<input type="submit" name="Upload" value="Upload file" onclick="__doPosback(System.Web.UI.WebControls.But ton,'');" id="Upload" />
What am I doing wrong? Any help is greatly appreciated.
Thanks,
M. Vuksanovic.