Proxy > Gmail Facebook Yahoo!

Oracle Solaris Goes to 11



solarisOracle has updated its Unix-based operating system Solaris, adding some features that would make the OS more suitable for running cloud deployments, as well as integrating it more tightly with other Oracle products, the company announced Wednesday.
Similar Articles:
"We looked at some of the big challenges that people were having in deploying cloud infrastructure, either in a private cloud or public cloud," said Charlie Boyle, senior director of product marketing. "In the release, we engineered out some of the complexity in managing a cloud infrastructure, and made it possible to run any Solaris application in a cloud environment."
Cloud deployments require even greater levels of automation and streamlining than a standard IT infrastructure would, noted Markus Flierl, Oracle vice president of software development. While an organization may run hundreds of Solaris servers, as it moves its applications to a cloud infrastructure, it may run them across thousands of virtual Solaris instances.
Solaris, a Unix implementation, was originally developed by Sun Microsystems, which Oracle acquired last year. While not as widely known for its cloud software, Oracle has been marketing Solaris as a cloud-friendly OS. In Oracle's architecture, users can set up different partitions, called Zones, inside a Solaris implementation, which would allow different workloads to run simultaneously, each within their own environment, on a single machine.
Oracle Solaris Zones has 15 times less overhead than a VMware implementation, Oracle asserted in its marketing literature. The company also touted that Zones had no artificial limitations set on memory, network, CPU or storage resources.
Many of the new features were designed to ease the administrative overhead of running a cloud-like infrastructure, Flierl said. One new feature, called Fast Reboot, will allow the system to boot up without doing the routine set of hardware checks, a move that can make system boot times up to two-and-a-half times faster, Oracle claimed. This feature can be handy in that an administrator applying a patch or software update across thousands of Solaris deployments can reboot them all the more quickly. "It allows you safely to upgrade your entire environment," Flierl said.
The new Solaris also features a new software management system, called Image Packaging System, that will keep track of a program's dependencies, or the libraries and other software that the program needs to run. The Image Packaging System keeps all the software packages in a system up-to-date, including those in a virtual environment.
Also adding to Solaris' cloud capabilities are new administrator controls that lock down the settings in individual Zones. Users can be limited in what changes they can make to the file system, or to the network settings. It can also limit the amount of network bandwidth each Zone can use. This is also the first version of the OS that allows users to virtualize networking resources, meaning supporting network cards can route traffic to appropriate virtual machines without any additional processing on the part of the server CPU itself.
In addition to work Oracle has done to make Solaris cloud-ready, the company has also closely tailored other Oracle products so that they can be coupled more easily to Solaris, including the Oracle Database 11g, Oracle Fusion Middleware 11g and the Oracle Enterprise Manager Ops Center administrative software package. By controlling an entire stack of software, the company can make "holistic" decisions over which part of the stack would be best suited to tweak to gain performance improvements, Flierl said.
Solaris 11, which complies to the Open Group's specifications for Unix implementations, can support any programs that were written for earlier versions of Solaris, dating back to Solaris 6. The company also runs the Oracle Solaris Binary Application Guarantee Program, which certifies more than 11,000 applications that can run on Solaris 6.
Solaris 11, released Wednesday, will run on both x86 and Oracle's Sparc-based processors.
[Read More...]


2G mobiles fare better in rural areas, study




2G mobiles fare better in rural areas, studyAccording to a new study by UK communication regulator Ofcom, the 2G mobile phones are better suited for people living in the rural areas when compared to the newer 3G phones.
The study found that older 2G phones were better for making, starting and completing calls from rural areas because they allowed more internal space for aerials. Both types of mobile devices offered similar voice quality but the 2G were better for calling.
The report acknowledged that 3G enabled Smartphones such as iPhone and Android-based Smartphones offers great access to Internet and other high speed services but could not match 2G phones in voice calls from rural areas. Ofcom noted that 2G phones passed its call test 97 per cent of the time while newer smartphones passed the test only 95 per cent of the time.
"In the more rural areas that the phones were tested, the feature/entry—level phones generally returned somewhat better performance than smartphones for call completion and call setup. This may be due to the reduced complexity of antenna on these devices and 2G phones not having issues in switching between 2G and 3G networks,” the study said.
The study also reveals that service providers ware working to improve connectivity in areas, where the connectivity ahs been low.
[Read More...]


Android is most attacked mobile platform, research




Android is most attacked mobile platform, research According to a new research by security firm, McAfee, Google's Android mobile OS was the most attacked mobile platform in the second quarter of the year.
The attacks on the open source platform rose 76 per cent in the quarter, which is presumably due to the ever increasing popularity of the platform and high sales of Android powered devices.
The open source nature of the platform allows developers to access framework API's used by the core Android team and also copy and improve upon certain components without starting from scratch. The same open source nature also poses problems related to malware as attackers access information about the platform and design more sophisticated malware.
The malware attackers also exploit the fact the Google's screening process for Android Marketplace is not as strict and rigid as that of the Apple App Store team. This allows anyone to upload any app on the store and start targeting users.
Experts suggest that Google should either introduce more stringent rules or it can launch a new App store with safer environment much like the Amazon App Store that offers only safe Android apps to the users in the US.
[Read More...]


More Facebook friends indicates more brain, study




More Facebook friends indicates more brain, study According to a new study, the size of a part of the brain is linked to the number of friends a person has on Facebook.
The study from University College London showed that people with a higher number of Facebook friends have denser grey matter in certain regions of the brain. This linking may indicate that social networking sites are altering people’s brains.
These brain regions are linked with creating memories of names and faces and also how one interprets social cues such as body movements. The study indicates people’s brains are getting affected by social networking sites or that people born with these kinds of brains behave in a different manner on Facebook.
"Social networks exist in many forms - in the real world, in cyberspace and in many other forms. They are a particular aspect of human behaviour that surrounds and affects many aspects of how we live our daily lives", study author Geraint Rees said.
The researchers used functional magnetic resonance imaging and created brain scans of 125 young college students at the University College London. The team compared the sizes of various brain regions with the number of the participant’s number of Facebook friends and friends in real life. The team also studied a separate group of 40 students and found a strong link between between the number of Facebook friends and the amount of "grey matter" in the amygdale.
The study was reported in the journal Proceedings of the Royal Society B: Biological Sciences.
[Read More...]


New study claims there is no link between mobiles and brain cancer




New study claims there is no link between mobiles and brain cancer A new study published recently has claimed that there is no link between mobile phones and brain cancer. However, some experts say that the risk cannot be completely ruled out.
The research conducted by the Institute of Cancer Epidemiology in Denmark included a study of 358,403 Danish cell phone users for over 17 years. It found subscribers of 13 years or more faced same level of risk as non- subscribers.
Patrizia Frei of the Danish Cancer Society's Institute of Cancer Epidemiology, lead author of the study said, "In general, our findings are in line with most of the epidemiological research that has been conducted to date. They are also in line with in vitro and in vivo studies that show no carcinogenic effects on the cellular level."
Frei and her team used Denmark's central population register, which is a huge database containing health records as well as cell phone plan details of every citizen. The research allowed the team to control for education and socioeconomic factors.
Even as the study shows that wireless communication is safe, experts say that further studies must be conducted in the field. The research follows an assessment by a panel of experts from the World Health Organization's International Agency for Research on Cancer that called cell phones a possible cause of cancer.
The assessment by the world panel had caused fear and discomfort among the billions of users of mobile phones around the world over the safe of wireless technologies used.
The study was published today in the journal BMJ.
[Read More...]


Technique to make brain tumours glow being tested in the UK



Technique to make brain tumours glow being tested in the UKA team of researchers in the UK are testing a technique to make brain tumours glow to help surgeons to operate.
The patients will be given drug that builds-up fluorescent chemicals and causes it to glow pink. The drug also marks the edges of the tumour more clearly allowing surgeons to remove it in a better way.
The trail will include more than 60 patients with glioblastoma. Removing of a brain tumour has to be precise as "functional tissue" needs to be protected. The GALA-5 trial of the drug 5-amino-levulinic will test the pioneering technique.
Dr Colin Watts, from Cambridge University and lead researcher said, "I strongly feel that our best opportunity to progress further is to emphasise funding of lab-based research and innovative trials, and the GALA-5 trial is a significant step forward in making this a reality."
He also expressed delight to see a partnership between Samantha Dickson Brain Tumour Trust and Cancer Research UK. This will allow more trials and clinicians ot be supported, according to him.
The research is funded by Samantha Dickson Brain Tumour Trust (SDBTT) and Cancer Research UK. Neil Dickson, founder and chair of trustees of SDBTT said that research in the field receives less funding and is the priority of SDBTT to create a balance in funding.
[Read More...]


TRAI to allow 200 SMSes per day from each SIM



TRAI to allow 200 SMSes per day from each SIMThe Telecom Regulatory Authority of India has said that I will allow mobile phone users to send up to 200 SMSes per day from each SIM card compared to just 100 SMSes per day allowed earlier.
"The authority has received representations from some of the service providers and consumers to increase the limit of 100 SMSes per day per SIM. The authority has considered these representations and decided to increase the limit of 100 SMSes per day per SIM to 200 SMSes per day per SIM," the regulator said in a statement.
The decision to implement a ceiling of 100 SMSs per day per SIM was taken just two months ago. The move was aimed at controlling spam messages. The regulator had later relaxed the norms for festivals season allowing non commercial unsolicited messages.
The cap also put an end to subscribers using multiple SIM cards to send text messages without registering themselves as telemarketers. Service providers such as Airtel, Vodafone and Idea Cellular had stopped offering message packs that allowed customers to send thousands of messages in a few weeks after the imposition of the 100 SMSs limit.
The decision to increase the limit to 200 SMSs came after TRAI received representations from consumers and service providers.
[Read More...]


Motorola launches Defy+ in India





Motorola launches Defy+ in IndiaPhone maker, Motorola has announced the launch of new Defy+ powered by Google's Android in the Indian market.
The handset, which was first revealed internationally on 15th August this year, is an improved model of Motorola Defy. The new device continues to have some aspects including dust and water proof characteristic of the earlier model.
The handset is powered by a 1 GHz processor and runs on Android 2.3 Gingerbread. It has a rear facing camera of 5 Megapixel camera with LED flash and comes with a 3.7-inch TFT Capacitive Touchscreen with a 480 x 854 pixel resolution. It comes with a 1700 mAh battery.
The Motorola Defy+ is available in India through two online stores including Flipkart and Letsbuy. As for connectivity options it has, 3G, EDGE/GPRS, Wi-Fi, Wi-Fi hotspot, Bluetooth 2.1 with A2DP, EDR as well as GPS with A-GPS support and Google Maps.
The handset has an expandable up to 32 GB through a microSD card slot.
The handtse will compete with the likes of Sony Ericsson's Xperia Ray and Active, LG's Optimus Black and the Galaxy S from Samsung.
The Motorola Defy+ is priced at Rs 17,990 in the Indian market.
[Read More...]


Secure Url



The following class will give you the support to pass querystring in encrypted rather than plain. 
Usage:
//WebForm1.aspx, From the sender
SecureUrl url = new SecureUrl("WebForm2.aspx?Key1=Value1&Key2=Value2");// WebForm2.aspx?param=HrxR96wU%2foN8VhElKlT32taPZLQzADf1Response.Redirect(url.ToString());
//WebForm2.aspx, To ReceiverSecureUrl url = new SecureUrl(Request.Url.PathAndQuery);
string Key1Value = url["Key1"];
string Key2Value = url["Key2"];
SecureUrl:
using System;
using System.IO;
using System.Text;
using System.Diagnostics;
using System.Collections;
using System.Collections.Specialized;
using System.Security.Cryptography;
using System.Web;


public sealed class SecureUrl{
    private const string ENCRYPTED_KEY_NAME = "param";
    private const string RETURN_URL = "returnUrl";
    private const string RETURN_PARAM = "returnParam";

    //DES Key size is 64 bit or 8 byte    private static readonly byte[] Key = new byte[] {33, 93, 171, 1, 85, 23, 231, 145};

    private string _pageUrl = string.Empty;
    private StringDictionary _queryString = new StringDictionary();

    public string this[string key]
    {
        [DebuggerStepThrough()]
        get        {
            if (_queryString.ContainsKey(key.ToLower()))
            {
                return _queryString[key];
            }

            return string.Empty;
        }
        [DebuggerStepThrough()]
        set        {
            if ((value != null) && (value.Trim().Length > 0))
            {
                _queryString[key.ToLower()] = value;
            }
            else            {
                _queryString.Remove(key.ToLower());
            }
        }
    }

    public string ReturnUrl
    {
        [DebuggerStepThrough()]
        get        {
            if (_queryString.ContainsKey(RETURN_URL))
            {
                return _queryString[RETURN_URL];
            }

            return string.Empty;
        }
        [DebuggerStepThrough()]
        set        {
            if ((value != null) && (value.Trim().Length > 0))
            {
                _queryString[RETURN_URL] = value;
            }
            else            {
                _queryString.Remove(RETURN_URL);
            }
        }
    }

    public string ReturnParameters
    {
        [DebuggerStepThrough()]
        get        {
            if (_queryString.ContainsKey(RETURN_PARAM))
            {
                return _queryString[RETURN_PARAM];
            }

            return string.Empty;
        }
        [DebuggerStepThrough()]
        set        {
            if ((value != null) && (value.Trim().Length > 0))
            {
                _queryString[RETURN_PARAM] = value;
                
            }
            else            {
                _queryString.Remove(RETURN_PARAM);
            }
        }
    }

    public SecureUrl(string fullUrl)
    {
        if (fullUrl.IndexOf('?') > 0)
        {
            string[] urlAndQueryString = fullUrl.Split('?');
            _pageUrl = urlAndQueryString[0];

            if (urlAndQueryString.Length > 1)
            {
                Parse(urlAndQueryString[1]);
            }
        }
        else        {
            _pageUrl = fullUrl;
        }
    }

    public SecureUrl(string url, 
    string queryString)
    {
        _pageUrl = url;
        Parse(queryString);
    }

    [DebuggerStepThrough()]
    public void Clear()
    {
        _queryString.Clear();
    }

    [DebuggerStepThrough()]
    public bool Contains(string key)
    {
        return _queryString.ContainsKey(key.ToLower());
    }

    [DebuggerStepThrough()]
    public void Remove(string key)
    {
        _queryString.Remove(key);
    }

    [DebuggerStepThrough()]
    public override string ToString()
    {
        return ToString(false);
    }

    [DebuggerStepThrough()]
    public string ToString(bool unicode)
    {
        StringBuilder queryString = new StringBuilder();

        foreach(DictionaryEntry entry in _queryString)
        {
            queryString.Append(entry.Key.ToString().ToLower());
            queryString.Append('=');
            queryString.Append(HttpUtility.UrlEncode(entry.Value.ToString()));
            queryString.Append('&');
        }

        if (queryString.Length > 0)
        {
            //Remove the last &            queryString.Remove(queryString.Length - 1, 1);
        }

        string encryptedQuery = Encrypt(queryString.ToString());

        string encodedQuery = HttpUtility.UrlEncode(encryptedQuery);

        if (unicode)
        {
            //Required if we are passing it to JavaScript            encodedQuery = HttpUtility.UrlEncodeUnicode(encodedQuery);
        }

        string result = string.Empty;

        if (encodedQuery.Length > 0)
        {
            result = _pageUrl + "?" + ENCRYPTED_KEY_NAME + "=" + encodedQuery;
        }
        else        {
            result = _pageUrl;
        }

        return result;
    }

    [DebuggerStepThrough()]
    private void Parse(string queryString)
    {
        string[] pairs = queryString.Split('&');

        if ((pairs != null) && (pairs.Length > 0))
        {
            for(int i = 0; i < pairs.Length; i++)
            {
                string[] pair = pairs[i].Split('=');
                string key = pair[0];
                string value = pair[1];

                value = HttpUtility.UrlDecode(value);

                if (string.Compare(key, ENCRYPTED_KEY_NAME, true) == 0)
                {
                    if (value.Length > 0)
                    {
                        string decryptedString = HttpUtility.UrlDecode(Decrypt(value));

                        string[] keyAndValues = decryptedString.Split('&');

                        if ((keyAndValues != null) && (keyAndValues.Length > 0))
                        {
                            for(int j = 0; j < keyAndValues.Length; j++)
                            {
                                string[] keyAndValue = keyAndValues[j].Split('=');

                                if ((keyAndValue != null) && (keyAndValue.Length == 2))
                                {
                                    _queryString.Add(keyAndValue[0].ToLower(), keyAndValue[1]);
                                }
                            }
                        }
                    }
                }
                else                {
                    _queryString.Add(key.ToLower(), value);
                }
            }
        }
    }

    [DebuggerStepThrough()]
    private static string Encrypt(string plain)
    {
        if ((plain == null) || (plain.Length == 0))
        {
            return null;
        }

        using(SymmetricAlgorithm crypto = CreateCrypto())
        {
            return System.Convert.ToBase64String(Read(crypto.CreateEncryptor(), Encoding.ASCII.GetBytes(plain)));
        }
    }

    [DebuggerStepThrough()]
    private static string Decrypt(string cipher)
    {
        if ((cipher == null) || (cipher.Length == 0))
        {
            return null;
        }

        using(SymmetricAlgorithm crypto = CreateCrypto())
        {
            return Encoding.ASCII.GetString(Read(crypto.CreateDecryptor(), System.Convert.FromBase64String(cipher)));
        }
    }

    [DebuggerStepThrough()]
    private static SymmetricAlgorithm CreateCrypto()
    {
        //Using DES as it is the fastest among the others        SymmetricAlgorithm crypto = new DESCryptoServiceProvider();

        crypto.Key = Key;
        crypto.IV = new byte[crypto.IV.Length];

        return crypto;
    }

    [DebuggerStepThrough()]
    private static byte[] Read(ICryptoTransform transformer,
    byte[] data)
    {
        using(MemoryStream ms = new MemoryStream())
        {
            using(CryptoStream cs = new CryptoStream(ms, transformer, CryptoStreamMode.Write))
            {
                cs.Write(data, 0, data.Length);
                cs.FlushFinalBlock();

                return  ms.ToArray();
            }
        }
    }
}
[Read More...]


Create An Ajax Style File Upload



If you visit Asp.net Ajax Forum, you will find hundreds of request on File Upload Control that it does not give Ajax version of the page when it is placed in an UpdatePanel. Certainly, it is not possible, as the XMLHTTPRequest object that is used internally to post the form does not support file upload. In this post I will show you how to create Ajax like version of the file upload. The trick is very simple, I will use an Iframe to upload the file so the whole page does not get refreshed and when the post is in progress it will show a dummy progress. The following shows you the screenshots of the solutions:

Initial In Progress Complete
Now lets discuss the implementation part, starting with the Main page markup.
<fieldset>
    <legend>Photo Upload Demo</legend>
    <div id="divFrame">
        <iframe id="ifrPhoto" onload="initPhotoUpload()" scrolling="no" frameborder="0" hidefocus="true" 
style="text-align:center;vertical-align:middle;border-style:none;margin:0px;width:100%;height:55px" src="PhotoUpload.aspx"></iframe>
    </div>
    <div id="divUploadMessage" style="padding-top:4px;display:none"></div>
    <div id="divUploadProgress" style="padding-top:4px;display:none">
        <span style="font-size:smaller">Uploading photo...</span>
        <div>
            <table border="0" cellpadding="0" cellspacing="2" style="width:100%">
                <tbody>
                    <tr>
                        <td id="tdProgress1">&nbsp; &nbsp;</td>
                        <td id="tdProgress2">&nbsp; &nbsp;</td>
                        <td id="tdProgress3">&nbsp; &nbsp;</td>
                        <td id="tdProgress4">&nbsp; &nbsp;</td>
                        <td id="tdProgress5">&nbsp; &nbsp;</td>
                        <td id="tdProgress6">&nbsp; &nbsp;</td>
                        <td id="tdProgress7">&nbsp; &nbsp;</td>
                        <td id="tdProgress8">&nbsp; &nbsp;</td>
                        <td id="tdProgress9">&nbsp; &nbsp;</td>
                        <td id="tdProgress10">&nbsp; &nbsp;</td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
</fieldset>
As you see that we are using few divs to show and hide the upload form and the progress bar. The important thing is we are binding the initPhotoUpload in the frame load event. Now let us check the iframe source page markup.
<form id="photoUpload" enctype="multipart/form-data" runat="server">
    <div>
        <input id="filPhoto" type="file" runat="server"/>
    </div>
    <div id="divUpload" style="padding-top:4px">
        <input id="btnUpload" type="button" value="Upload Photo" />
    </div>
</form>
The iframe source page contains only a file upload control and a button to post the form. Now lets get back to the main page initPhotoUpload function and lets check how it is implemented:
function initPhotoUpload()
{
    _divFrame = document.getElementById('divFrame');
    _divUploadMessage = document.getElementById('divUploadMessage');
    _divUploadProgress = document.getElementById('divUploadProgress');
    _ifrPhoto = document.getElementById('ifrPhoto');

    var btnUpload = _ifrPhoto.contentWindow.document.getElementById('btnUpload');

    btnUpload.onclick = function(event)
    {
        var filPhoto = _ifrPhoto.contentWindow.document.getElementById('filPhoto');

        //Baisic validation for Photo
        _divUploadMessage.style.display = 'none';

        if (filPhoto.value.length == 0)
        {
            _divUploadMessage.innerHTML = '<span style=\"color:#ff0000\">Please specify the file.</span>';
            _divUploadMessage.style.display = '';
            filPhoto.focus();
            return;
        }

        var regExp = /^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))(.jpg|.JPG|.gif|.GIF|.png|.PNG|.bmp|.BMP)$/;

        if (!regExp.test(filPhoto.value)) //Somehow the expression does not work in Opera
        {
            _divUploadMessage.innerHTML = '<span style=\"color:#ff0000\">Invalid file type. Only supports jpg, gif, png and bmp.</span>';
            _divUploadMessage.style.display = '';
            filPhoto.focus();
            return;
        }

        beginPhotoUploadProgress();
        _ifrPhoto.contentWindow.document.getElementById('photoUpload').submit();
        _divFrame.style.display = 'none';
    }
}
Once the iframe is loaded we are setting few module level variables (All module level variables are prefixed with _ (underscore) character in this example) to DOM elements, we are also getting the reference of the Upload button which is in the iframe and creating its click handler. In the click handler first we are doing few basic validation such as the file upload control is not empty or the file that is specified has a valid image file extension. Once the validation qualifies then we are calling the beginPhotoUploadProgress function (discussed next) and submitting the iframe form. The beginPhotoUploadProgress function is the first of three functions which are used to show the dummy progress bar. Let us see how these functions are written:
function beginPhotoUploadProgress()
{
    _divUploadProgress.style.display = '';
    clearPhotoUploadProgress();
    _photoUploadProgressTimer = setTimeout(updatePhotoUploadProgress, PROGRESS_INTERVAL);
}

function clearPhotoUploadProgress()
{
    for (var i = 1; i <= _maxLoop; i++)
    {
        document.getElementById('tdProgress' + i).style.backgroundColor = 'transparent';
    }

    document.getElementById('tdProgress1').style.backgroundColor = PROGRESS_COLOR;
    _loopCounter = 1;
}

function updatePhotoUploadProgress()
{
    _loopCounter += 1;

    if (_loopCounter <= _maxLoop)
    {
        document.getElementById('tdProgress' + _loopCounter).style.backgroundColor = PROGRESS_COLOR;
    }
    else 
    {
        clearPhotoUploadProgress();
    }

    if (_photoUploadProgressTimer)
    {
        clearTimeout(_photoUploadProgressTimer);
    }

    _photoUploadProgressTimer = setTimeout(updatePhotoUploadProgress, PROGRESS_INTERVAL);
}
As we can see we are basically using the timer (window.setTimeout) to show the dummy progress in these functions. Now lets see what happens in the server side when the iframe page posts.
private const string SCRIPT_TEMPLATE = "<" + "script " + "type=\"text/javascript\">window.parent.photoUploadComplete('{0}', {1});" + "<" + "/script" + ">";

private void Page_Load(object sender, EventArgs e)
{
    if (IsPostBack)
    {
        //Sleeping for 10 seconds, fake delay, You should not it try at home.
        System.Threading.Thread.Sleep(10 * 1000);
        UploadPhoto();
    }
}

private void UploadPhoto()
{
    string script = string.Empty;

    if ((filPhoto.PostedFile != null) && (filPhoto.PostedFile.ContentLength > 0))
    {
        if (!IsValidImageFile(filPhoto))
        {
            script = string.Format(SCRIPT_TEMPLATE, "The uploaded file is not a valid image file.", "true");
        }
    }
    else
    {
        script = string.Format(SCRIPT_TEMPLATE, "Please specify a valid file.", "true");
    }

    if (string.IsNullOrEmpty(script))
    {
        //Uploaded file is valid, now we can do whatever we like to do, copying it file system,
        //saving it in db etc.

        //Your Logic goes here

        script = string.Format(SCRIPT_TEMPLATE, "Photo uploaded.", "false");
    }

    //Now inject the script which will fire when the page is refreshed.
    ClientScript.RegisterStartupScript(this.GetType(), "uploadNotify", script);
}

private static bool IsValidImageFile(HtmlInputFile file)
{
    try
    {
        using (Bitmap bmp = new Bitmap(file.PostedFile.InputStream))
        {
            return true;
        }
    }
    catch (ArgumentException)
    {
        //throws exception if not valid image
    }

    return false;
}
In the server side we are first doing some basic validation such as the file upload control has file and the file is a valid image file. Once the validation is done we are injecting some javascript which will be executed when the page is loaded in the browser. The javascript calls the main page photoUploadComplete function which shows the success/failure or the validation message of the upload. Lets see the javascript function photoUploadComplete of the main page.
function photoUploadComplete(message, isError)
{
    clearPhotoUploadProgress();

    if (_photoUploadProgressTimer)
    {
        clearTimeout(_photoUploadProgressTimer);
    }

    _divUploadProgress.style.display = 'none';
    _divUploadMessage.style.display = 'none';
    _divFrame.style.display = '';

    if (message.length)
    {
        var color = (isError) ? '#ff0000' : '#008000';

        _divUploadMessage.innerHTML = '<span style=\"color:' + color + '\;font-weight:bold">' + message + '</span>';
        _divUploadMessage.style.display = '';

        if (isError)
        {
            _ifrPhoto.contentWindow.document.getElementById('filPhoto').focus();
        }
    }
}
The function simply hides the progress bar and shows the upload control then it shows the message in colored text which is sent from the server.
I hope you can easily implment it in Ajax UpdatePanel, if not please let me know, I will show it in next post.

[Read More...]



Send mail to your Friends.  

Expert Feed

 
Return to top of page Copyright © 2011 | My Code Logic Designed by Suneel Kumar