Showing posts with label file. Show all posts
Showing posts with label file. Show all posts

Saturday, March 24, 2012

Upgrade error: Could not load file or assembly Microsoft.Web.Extensions, Version=1.0.61025

I have upgraded from Beta 2 to RC1 and followed all of the upgrade instructions, but I'm still getting this error:

Error 26 Could not load file or assembly 'Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

I'm aware that Microsoft.Web.Extensions is now System.Web.Extensions, but I can't find where the old reference is!!!

I have searched all the files in my project for "Microsoft.Web.Extensions" as well as the machine.config. I'm currently searching every file on my hard drive for this reference and still can't find it.

Any ideas?

Thanks,

Still looking for some help...
Do you have the ControlToolkit on your site? We had that error before we updated to the newest toolkit.

I've found you have to move the DLL files form the .NET version folder on the hard drive to the bin folder in the site otherwise they need to be in the GAC.

I'm finding other problems with it. Like [no relevant source code lines] gotta be permissions or something.

Still looking...


I have the same problem and finally found out that the reference to Microsoft.Web.Extensions is in my web.config.

Have to go through and changes all "Microsoft.Web" to "System.Web" (mainly under the<pages><controls> tag).

UPLOAD FILE WITH ATLAS

I need a sample that allows to upload files using ATLAS.

Thanks in advance!

hello.

can you give more details on what you're after?


Well, I need to upload XML files from a WebBrowser (Internet Explorer, FireFox, etc) to the WebServer using UploadFile control.

How can I do it with ATLAS!?


hello.

unfortunally, by default, you can't do it without writting code to perform this action.


ok! Could you help me with this? Could you send me a sample to perform this action?


hello.

unfortunatelly, i still haven't written anything that let's me perform that kind of action. i'll report abck if i manage to get something working.

Upload Progress Bar

So I'm taking a file and loading it into a stream and then displaying that file. I'm wondering if there is a way to add a progress bar that will show how much of the upload has finished. I've googled for something that tells me how to track the completion of the upload into the stream, but couldn't find anything.

Can someone point me in the right direction?

Here's my code:


1FileStream fs =new FileStream(FileUpload1.FileName, FileMode.OpenOrCreate, FileAccess.Read);
2 Byte[] img =new Byte[fs.Length];
34 fs.Read(img, 0, Convert.ToInt32(fs.Length));
56 System.IO.MemoryStream ms =new System.IO.MemoryStream(img);
7//System.IO.Stream ps = new System.IO.MemoryStream(img);
8 //System.Drawing.Bitmap b = (System.Drawing.Bitmap)System.Drawing.Image.FromStream(ms);
9 //System.Drawing.Bitmap b = new System.Drawing.Bitmap(ps);1011 System.Drawing.Bitmap sb = (System.Drawing.Bitmap)System.Drawing.Image.FromStream(FileUpload1.PostedFile.InputStream);
1213 sb.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
On the other hand, what I need is an image upload with a preview and upload progress bar, where the preview is cached/dynamically generated and not stored on the disk. 
Thanks!

Hi,rksprst

Need a preview, you can do it like this:

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Default25 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string oIP = Context.Request.QueryString["oIP"];
MakeThumbnail(oIP, oIP + ".JPG", 100, 0, "W");
}
/// <summary>
///
/// </summary>
/// <param name="originalImagePath"></param>
/// <param name="thumbnailPath"></param>
/// <param name="width"></param>
/// <param name="height"></param>
/// <param name="mode"></param>
public void MakeThumbnail(string originalImagePath, string thumbnailPath, int width, int height, string mode)
{
System.Drawing.Image originalImage = System.Drawing.Image.FromFile(originalImagePath);

int towidth = width;
int toheight = height;

int x = 0;
int y = 0;
int ow = originalImage.Width;
int oh = originalImage.Height;

switch (mode)
{
case "HW":
break;
case "W":
toheight = originalImage.Height * width / originalImage.Width;
break;
case "H":
towidth = originalImage.Width * height / originalImage.Height;
break;
case "Cut":
if ((double)originalImage.Width / (double)originalImage.Height > (double)towidth / (double)toheight)
{
oh = originalImage.Height;
ow = originalImage.Height * towidth / toheight;
y = 0;
x = (originalImage.Width - ow) / 2;
}
else
{
ow = originalImage.Width;
oh = originalImage.Width * height / towidth;
x = 0;
y = (originalImage.Height - oh) / 2;
}
break;
default:
break;
}


System.Drawing.Image bitmap = new System.Drawing.Bitmap(towidth, toheight);


System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmap);


g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;


g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;


g.Clear(System.Drawing.Color.Transparent);


g.DrawImage(originalImage, new System.Drawing.Rectangle(0, 0, towidth, toheight),
new System.Drawing.Rectangle(x, y, ow, oh),
System.Drawing.GraphicsUnit.Pixel);
try
{
HttpResponse httpResponse = Context.Response;
httpResponse.Clear();
httpResponse.ContentType = "Image/Jpeg";
bitmap.Save(httpResponse.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
httpResponse.End();
}
catch (System.Exception e)
{
throw e;
}
finally
{
originalImage.Dispose();
bitmap.Dispose();
g.Dispose();
}
}
}

Use it like this:

<%@. Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
protected void Button1_Click(object sender, EventArgs e)
{
ImageMap1.ImageUrl = "Default25.aspx?oIP=C:\\Documents and Settings\\v-jyyin\\Desktop\\IMG\\c4960543c39f4f0c71b53bf27aa34e65.jpg";
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server" method="get">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
<asp:ImageMap ID="ImageMap1" runat="server">
</asp:ImageMap></div>
</form>
</body>
</html>

By the way,I don't think you can get the progress bar without ActiveX.

Uploading a file in a updatepanel

Basically, I am trying to do an upload inside the updatepanel. (Ajax, C#, Visual Studio 2005)

I don't think it's possible to do it without full page post back.. (If I am wrong, please let me know how!!)

So, I decided to put a not-visible button in master.master page. The code follows below.

<%@dotnet.itags.org. Master Language="C#"
AutoEventWireup="true"
CodeFile=" Master.master.cs"
Inherits="Master" %
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<!--General Stylesheet-->
<link rel="stylesheet" href="http://links.10026.com/?link=css/gen_style.css" type="text/css" />
</head
<body style="border:0px; margin:0px;"
<form id="submitTicketForm" method="post" runat="server" enctype="multipart/form-data">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel ID="MainLoginPanel" runat="server">
<ContentTemplate
<!--Top Logo-->
<div class="headerTop">
<div id="header">
<div class="logo"></div>
<div class="login">
<asp:Panel runat="server" ID="LogOutPanel">
<asp:Button OnClick="LogOut_Click" runat="server" ID="LogOut" Text="Click here to logout" Width="142" CssClass="myBtn" />
</asp:Panel>
</div>
</div>
</div
<!--Tab_Panel-->
<asp:Panel runat="server" ID="Tab_Panel">
<div class="tabTop">
...
</div>
</asp:Panel>
<div class="contentplaceholder">
<asp:contentplaceholder id="mainContent" runat="Server"></asp:contentplaceholder>
</div>
<asp:Button id="UploadButton" Visible="false" runat="server" Text="Submit" CssClass="myBtn" OnClick="sendData" />
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="UploadButton" />
</Triggers>
</asp:UpdatePanel
<!--Page Footer-->
<div class="footer">Footer</div>
</form>
</body>
</html
Then the below is the code for NewTicket.aspx. If I press the btn_sendData button, I need to trigger the UploadButton button in the master's page.

<%@dotnet.itags.org. Page Language="C#"
MasterPageFile="~/Master.master"
AutoEventWireup="true"
CodeFile="NewTicket.aspx.cs"
Inherits="NewTicket"
Title="SPN Ticketing System - Submit a New Ticket" %
<%@dotnet.itags.org. Register Assembly="AjaxControlToolkit"
Namespace="AjaxControlToolkit"
TagPrefix="ajaxToolkit" %
<asp:Content ID="Content1" ContentPlaceHolderID="mainContent" Runat="Server">
<asp:FileUpload ID="fileChoose" runat="server" />
<asp:Button id="btn_sendData" runat="server" Text="Submit" CssClass="myBtn" OnClick="TriggerMasterUploadBtn" />
</asp:Content
Now, the below is the partial code from NewTicket.aspx.cs.

protected void TriggerMasterUploadBtn(object sender, EventArgs e)
{

Control btnControl = Page.Master.FindControl ( "UploadButton" );
Button btn = (Button)btnControl;
//I have the control but I don't know what to do!
}

I've been pulling my hair for hours for this thing.
Your help is GREATELY appreciated!
Thank you again.

It is not possible to do a file upload without doing a full post back. If you have the fileupload inside the update panel you will need to add a trigger to the button that will take care of the uploading. There have been many posts on this forum about this, and some have some good work arounds.

http://forums.asp.net/thread/1444713.aspx

There is alink on one of the threads that is to an MSDN page that listed all the controls that currently do not work with update panel but I can't seem to find it. If anyone does, please post it here.

Uploading file during onchange

I try to upload file in server during user select file:

<inputid="iupload"runat="server" type="file"style="width:1px"/>
<inputtype="hidden"id="hdName"runat="server"/>

<scriptlanguage="javascript">
function Doo(){
document.getElementById('hdName').value = document.getElementById('iupload').value;// to check path
WebForm_DoCallback('__Page',document.getElementById('iupload').value,CallbackFunction,'context',null,false);returnfalse;
}
</script>

and on server side:

protectedvoid Page_Load(object sender, EventArgs e)
{
string argClientFunction ="";
string cScript = ClientScript.GetCallbackEventReference(this, argClientFunction,"CallbackFunction","'context'","null",false);
string f=@dotnet.itags.org."
javascript:Doo();";
iupload.Attributes.Add("onchange", f);

string scr ="<script language=javascript>";
scr +="function CallbackFunction(result, context)";
scr +="{";
scr +="document.getElementById('spUploaded').innerText += 'Done';";
scr +=" return false;";
scr +="}";
scr +="</script>";
RegisterStartupScript("scr" +this.ClientID, scr);

}


publicvoid UploadFile(string fileName)
{
// try to upload file to server
}
publicstring GetCallbackResult()
{
UploadFile(evArg);

evArg = String.Empty;

return evArg;
}
publicvoid RaiseCallbackEvent(string eventArgument)
{
evArg = eventArgument;
}

Problem occur in UploadFile(...): When I try to get iupload.PostedFile for file uploading it's null. I can get file name only.

How can I upload file normally without postback with onchange ?

I need upload file to server as Gmail or Yahoo Mail!

File uploads require a full postback. There has been a lot of talk on here about sites such as gmail that appear to asynchronously load a file. At this point, the only way that I have heard of this successfully implemented is by using IFrames and have another page that does the full postback, but doesn't look like it.


Thank you! I have heard about Iftame to upload files. Have you any information about this?


Not really... we haven't got into handling file uploads very often, and if we do, we would probably use the telerik fileupload control since we have the suite and I believe it handles very large files much better that the built in fileupload for asp.net. When I tested both of them, I was able to crash IIS with the built in control by trying to upload a dvd image because it seemed to check for the file size only after it had been processed through IIS, but the telerik control seemed to do that in pieces which didn't cause it to lock up.

Uploading File doesnt work when using UpdatePanel!

Hi,

Uploading files works fine but when i tried to include everything inside the UpdatePanel then i can no longer upload. The reason is that on my PostBack, the input values(file1, file2, file3, file4) have empty values..

<tableborder="0"cellspacing="0"cellpadding="0"style="border-collapse: collapse;">

<trid="fileInput1"><tdalign="left"class="VerdanaXXSmallBlue">1) </td>

<td><inputid="file1"type="file"runat="server"class="VerdanaXSmallBlue"style="width: 100%"/></td></tr><trid="fileInput2">

<tdalign="left"class="VerdanaXXSmallBlue">2) </td>

<td><inputid="file2"type="file"runat="server"class="VerdanaXSmallBlue"style="width: 100%"/></td></tr><trid="fileInput3"><tdalign="left"class="VerdanaXXSmallBlue">3) </td><td><inputid="file3"type="file"runat="server"class="VerdanaXSmallBlue"style="width: 100%"/></td></tr><trid="fileInput4"><tdalign="left"class="VerdanaXXSmallBlue">

4)

</td><td><inputid="file4"type="file"style="width: 464px"class="VerdanaXSmallBlue"runat="server"/></td></tr></table>

Hi Kiril,

The Ajaxdocumentation states that theFileUpload control is not compatible with partial-page updates and is therefore not supported inside an UpdatePanel. To use aFileUpload control inside anUpdatePanel control, set the postback control that submits the file to be aPostBackTrigger for the panel.

HTH


cool. thanks

Uploading file in chunks using AJAX (or asynchronous call)

Hiya guys,

Just done some work with FileUpload in my AJAX-enabled web application, unfortunately using full-postback, so want to change it using AJAX.

Got some ideas, but not if that way will work, so need some bright ideas maybe from someone who already done something similar. Basically I want to achieve partial postback on uploading files in chunks, so not using the server's memory which can lead to server restart... Just saw some very interesting code snippets, but those were using ActiveXObject, which I would like to avoid.Is it possible to use a ScriptManager in some way to achieve similar results?
I guess it would be using XMLHTTP, as I already did some digging, but I mainly seen this using ActiveXObject.

Anyone with such an experience?

Thanks

Ben

hello.

old ajax code that needs to be ported to the asp.net ajax version, but it might still point you in the right direction:

http://msmvps.com/blogs/luisabreu/archive/2006/12/14/uploading-files-without-a-full-postback.aspx


Hi,

Here is a sample:

PageA.aspx:

<%@. Page Language="C#" %>

<%@. Register src="http://pics.10026.com/?src=Gallery.ascx" TagName="Gallery" TagPrefix="uc1" %>
<%@. Register src="http://pics.10026.com/?src=Upload.ascx" TagName="Upload" TagPrefix="uc2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
Upload1.Button1clientID = Gallery1.Button1clientID;
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>

</div>
<uc1:Gallery ID="Gallery1" runat="server" />
<uc2:Upload ID="Upload1" runat="server" />
</form>
</body>
</html>

Gallery.ascx:

<%@. Control Language="C#" ClassName="Gallery" %>

<script runat="server">

protected void Button1_Click(object sender, EventArgs e)
{
}

protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = DateTime.Now.ToString();
}

public string Button1clientID
{
get
{
return Button1.ClientID;
}
}

</script>

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<div style="visibility:hidden"><asp:Button ID="Button1" runat="server" OnClick="Button1_Click" UseSubmitBehavior="false" Text="Button" /></div>
</ContentTemplate>
</asp:UpdatePanel>

Upload.ascx:

<%@. Control Language="C#" ClassName="Upload" %>

<script runat="server">
private string buttonclientID = "";
public string Button1clientID
{
set
{
buttonclientID = value;
}
}
</script>

<script type="text/javascript">
function submitForm(frameName,upload){
document.forms[0].action="PageA.aspx"
document.forms[0].target=frameName;
window.setTimeout(function(){
var uploadE=document.getElementById(upload);
uploadE.parentElement.appendChild(document.createTextNode(uploadE.value));
uploadE.parentElement.replaceChild(uploadE.cloneNode(true),uploadE);
},100);
document.forms[0].submit();
document.getElementById("<%=buttonclientID %>").click();
}
</script>

<div id="Div1">
<input type="file" name="upload" id="upload" />
<button onclick="javascript:submitForm('hiddenFrame','upload')">Upload</button>
<iframe name="hiddenFrame" src="http://pics.10026.com/?src=blank.htm" id="hiddenFrame" style="display: none">
</iframe>
</div>

An Ajax Alternative for FileUpload:

We've all embraced Ajax as a revolutionary technology, but many of us forget (or are not aware) of asynchronous posts in the times before XmlHttp requests. Our good old friend the IFrame used to be the preferred option for asynchronous http communications. Because an iframe is in essence it's own browser window, it can be used to fire off asynchronous requests (both POST and GET). However, even more important is an IFrame's ability to be a 'target' of a form POST. By adding an IFrame to the page and setting it as the target of the form post, you can in essence create an asynchronous file transfer.

For more help about Ajax Alternative for FileUpload, Please check: http://blogs.infragistics.com/blogs/tony_lombardo/archive/2007/04/09/file-uploads-where-s-the-ajax.aspx

NOTE:This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you.

Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations

regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet,

and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

Best Regards,


hello.

well, simple code, but i still prefer my code since it'll return the response for the upload.

Uploading files

I am using ajax 1.0, when i am uploading files, it does not working properly, it is not uploading any images. I heared that file upload will not work in ajax, is it true? help appreciated

Hi sreejithpkrishnan,

I don't know if you want to uploadfiles in combination wioth an update panel if so check the summary below:

Controls that are not compatible with updatepanel controls

The following ASP.NET controls are not compatible with partial-page updates, and are therefore not supported inside anUpdatePanel control:

TreeView andMenu controls.


Hi,

the FileUpload, and several other controls, don't play nicely together with the UpdatePanel control. You can however use inside it but must set it to be a PostBackTrigger for the UpdatePanel. Read more about ithere andhere. The last link provides a sample for the FileUpload control that works together with the UpdatePanel control.

Grz, Kris.


hello.

In the past, I've written an extender which lets you upload files without performing a postback. it was written for the beta 2 or rc version (really can't recall it), but you should be able to update it to the current release without having much problems.

http://msmvps.com/blogs/luisabreu/archive/2006/12/14/uploading-files-without-a-full-postback.aspx