ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
Google
 
Categories  >>  Code Snippets  >>  Programming Code  >>  Dot Net Code  >>  ASP.NET Code
 
 


 

 
 ASP.NET Code interview questions  ASP.NET Code Interview Questions
 VB.NET Code interview questions  VB.NET Code Interview Questions
 C Sharp Code interview questions  C Sharp Code Interview Questions
 ADO.NET Code interview questions  ADO.NET Code Interview Questions
Question
working with fileUpload ?
 Question Submitted By :: Guest
I also faced this Question!!     Rank Answer Posted By  
 
  Re: working with fileUpload ?
Answer
# 1
<asp:FileUpload ID="FileUpload1" runat="server"
onchange="change(this);" />


//js
function change(fileupload) {

            if (fileupload.value.indexOf('jpg') == '-1') {
                document.getElementById('TextBox1').value =
'Nopicture';
                alert('Select *.jpg file only');
            }
            if (fileupload.value.indexOf('jpg') != '-1') {
                document.getElementById('TextBox1').value =
'haspicture';
             }

         }

         function changevalue() {
             if
(document.getElementById('FileUpload1').value == '') {
                 alert('Please select a file');
                 return false;
             }
              if
(document.getElementById('FileUpload1').value !='')
               {
                  if
(document.getElementById('FileUpload1').value.indexOf('jpg')
== '-1') {

                      alert('upload *.jpg images only');
                      return false;
                  }
              }

 
//code behind
protected void btnUpload_Click(object sender, EventArgs e)
    {
        if (btnUpload.Text == "Upload")
        {
            if (FileUpload1.HasFile)
            {

                Stream imgStream =
FileUpload1.PostedFile.InputStream;

                int imgLen =
FileUpload1.PostedFile.ContentLength;
                byte[] img = new byte[imgLen];
                int n = imgStream.Read(img, 0, imgLen);
                Session["Picture"] = img;
                lblMessage.Text = "Attached";
                btnUpload.Text = "Remove";
            }
            else
            {
                Session["Picture"] = null;
            }

        }
        else
        {
            Session["Picture"] = null;
            btnUpload.Text = "Upload";
            lblMessage.Text = "Removed";
        }
    }
 
Is This Answer Correct ?    0 Yes 0 No
Guest
 

 
 
 
Other ASP.NET Code Interview Questions
 
  Question Asked @ Answers
 
Give coding for Exception Handling Techniques in ASP.NET? Microsoft3
How to add checkbox to datagrid?  4
How to Create Scrollable Micro Windows?  2
Code for Sending E-Mail with System.Web.Mail?  1
how to upload a photo? i need to use it in a matrimonial applicaton...  1
HOw to Build a Nested GridView Control with ASP.NET?  1
working with fileUpload ?  1
Code for a Simple Way to Write XML in .NET (XmlTextWriter)  1
How we implement the paypal in my website and how we make a payment through Credit Card.  2
hold checkbox values  4
how to upload an excel in c# ASP.Net?  2
How to integrate the regional language in asp.net and c# like Telugu, Hindi etc,. send a sample program NIIT2
what is the value that reside in a hidden field when no value is assigned to it?how it can be used in a if statement??  1
What do you create for easier access of data? NIIT2
Data Reader Vs DataSet TCS1
Code for Getting Information About A File?  1
Give coding for Implementing a Fixed GridView Header in ASP.NET?  1
how can we close a web page in asp.net without using jscript?  1
How to Export Data to Excel? Eastcom-Systems3
how to design a ListView control?  1
 
For more ASP.NET Code Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com