PDA

View Full Version : Reg. downloading image from server



After2050
23 Jun 2010, 10:13 PM
Hi friends,

I'm using both extjs and extdirect configured in my ASP.NET MVC application. I want to download an image from the server, can I do this by extjs or I've to go for extdirect? How?

Dnana | Trigent

Condor
23 Jun 2010, 11:32 PM
Why the distinction between Ext JS and Ext.Direct?

Downloading images using XmlHttpRequest isn't really useful. Instead, you set the src of an <image> tag and wait for the load or error event.

After2050
24 Jun 2010, 3:08 AM
Hi Condor,

Can you give me a little sample code because just setting the src of the <image> tag not displaying the image.

Dnana | Trigent

Condor
24 Jun 2010, 3:39 AM
Are you looking for an ImageField?

Ext.ns('Ext.ux');
Ext.ux.form.ImageField = Ext.extend(Ext.form.DisplayField, {
fieldClass: 'x-form-image-field',
defaultAutoCreate: {
tag: 'img',
src: Ext.BLANK_IMAGE_URL
},
constructor: function (config) {
Ext.ux.form.ImageField.superclass.constructor.call(this, config);
this.addEvents('load', 'error');
},
onRender : function(ct, position){
Ext.ux.Image.superclass.onRender.call(this, ct, position);
this.relayEvents(this.el, ['load', 'error']);
},
getRawValue: function () {
return this.rendered ? this.el.dom.src : this.value;
},
setRawValue: function (value) {
this.value = value;
if (this.rendered) {
el.dom.src = value;
}
}
});
Ext.reg('image', Ext.ux.form.ImageField);

After2050
24 Jun 2010, 8:47 PM
Hi Condor,

That's what I'm looking for. Thanks.

Dnana | Trigent