Thursday, 20 February 2014

Check Image size and type using javascript in asp.net

 function GetFileSizetypeIMG() {
    var maxsize=2*1024*1024//1mb=1*1024*1024
        var aspFileUpload = document.getElementById("<%=Upload1.ClientID%>");
        var filesze = aspFileUpload.files[0].size;
        var fileName = aspFileUpload.value;
        var ext = fileName.substr(fileName.lastIndexOf('.') + 1).toLowerCase();
        if (!(ext == "zip")) {
            alert("Invalid file type, must select a (*.zip) file");
            return false;
        }
        if (filesze > maxsize) {
            alert("Selected file not more than " + maxsize/(1024*1024)+"MB");
            return false;
        }
        return false;
    }

Friday, 7 February 2014

Copy Images from one to another folder using c# or asp.net

Create Directory-
string diretorypath= Application.StartupPath;
string ImagePath = diretorypath+ "\\" + "Images_" + DateTime.Now.ToString("ddMMyyyy") + "_" + DateTime.Now.ToString("hhmmss");

if(!Directory.Exists(Sfilepthe))//create directory
                Directory.CreateDirectory(ImagePath);


//Copy files

 public void CopyFiles(string sourcePath, string destinationPath, string sFileName)
        {
            try
            {
                string Sfilepthe = sourcePath + "\\" + sFileName;
                string Sdestination = destinationPath + "\\" + sFileName;
                if (File.Exists(Sfilepthe))
                {
                    File.Copy(Sfilepthe, Sdestination, true);
                }
            }
            catch (Exception ex)
            { }
        }

Wednesday, 20 November 2013

IIS Error- Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).


For this fallow the fallowing steps-

 Enable the ASP.NET authentication for default website (in IIS) then create Desktop folder at C:\Windows\System32\config\systemprofile\Desktop.

step1 :  Go to run type dcomcnfg 
Step2:   Click >Component services >Computes >My Computer>Dcom config> and select microsoft Excel Application> 
Step3:   Right Click on Microsoft Excel Application>Properties>Security Tab
Step4-Under-Launch and activation permission->Customise->Edit->Add--type-(IIS_IUSRS) 
-> ok -> Allow Permission-Local Lounch and Local Activation
Step5- Repeate Step4 for Under Access Permission

Reference--http://www.youtube.com/watch?v=ijfb3E_7t3o

IIS-Error Resolve--Microsoft Excel cannot open or save any more documents because there is not enough available memory or disk space. • To make more memory available, close workbooks or programs you no longer need. • To free disk space, delete files you no longer need from the disk you are saving to.


For this fallow the fallowing steps-
step1 :  Go to run type dcomcnfg 
Step2:   Click >Component services >Computes >My Computer>Dcom config> and select micro soft Excel Application> 
Step3:   Right Click on Microsoft Excel Application>Properties>Give Asp.net Permissions 
Step 4: Select Identity table >Select interactive user >select ok

Friday, 15 November 2013

Restrict Ajax Calender future and past date using javascript

<script type="text/ecmascript">

    function checkDates(sender, args) {
       // alert(sender._selectedDate + "    enter    " + new Date());
        if (sender._selectedDate > new Date()) {
            alert('Date must be less than Today');
            sender._selectedDate = new Date();
            // set the date back to the current date
            sender._textbox.set_Value(sender._selectedDate.format(sender._format))
        }
    }
</script >

//HTML
 <asp:TextBox runat="server"  ID="dtForm"  Enabled="False" ></asp:TextBox>

<asp:CalendarExtender ID="CalendarExtender1" runat="server" PopupButtonID="cal_Surveyor"
TargetControlID="dtForm" OnClientDateSelectionChanged="checkDates"  Enabled="True" Format="dd/MM/yyyy"></asp:CalendarExtender>

How to highlight selected text in notepad++

  –> To highlight a block of code in Notepad++, please do the following steps step-1  :- Select the required text. step-2  :- Right click...