2
Answers

Problem in Receiving the files that had been attached with my web form

Hello there!,

    I am having trouble in receiving the attached files from a html file input !.

First of all i have added a master  page and made this form as a content page!

Actaully the view state of this html file input is not maintaining when the page is posted back!.    It says Request.Files.Count=0 even i had attached a file!

Before adding the master page it worked fine!

  Could you please tell me a solution!,
My Code is

if (Request.Files.Count != 0)
        {
            HttpFileCollection files = Request.Files;
            DataTable Table4 = new DataTable();


            DataColumn Doc_Name = new DataColumn();
            Doc_Name.ColumnName = "Documents";

            DataColumn Remove = new DataColumn();
            Remove.ColumnName = "Remove";
 
            Table4.Columns.Add(Doc_Name);

            Table4.Columns.Add(Remove);
 for (int p = 0; p < files.Count; p++)
                {
                    HttpPostedFile file = files[p];

                    if (file.ContentLength == 0)
                    {
                        continue;
                    }
                    string c = System.IO.Path.GetFileName(String.Format(file.FileName));

                    string path = Server.MapPath("../")+"Upload"+ @"\" +c;
                                       

                    StreamWriter streamWriter;
                    streamWriter = File.CreateText(path);
                    streamWriter.Close();

                    file.SaveAs(path);

                    Table4.Rows.Add(p);
                                
                    Table4.Rows[p]["Documents"] =c;
                    Table4.Rows[p]["Remove"] = "Remove";

                   }
                Session["DOC_INFO"] = Table4;
}

 

 

Answers (2)

0
Photo of Ranjit Powar
NA 8.1k 496.8k 9y
try jquery as below
 
$('#TextBox2').focus(function(){
    $('#TextBox2').val($('#TextBox1').val());
}); 
 
 
 
 
 
If it helps you select it as correct answer. 
Accepted
0
Photo of parul jain
NA 140 10.4k 9y
Sir how we will define loop in following statement :
 
 
$('#gvDetails_txtPackaging_0').blur(function () {
if ($('#gvDetails_txtPackaging_0').val() > $('#gvDetails_txtQuantity_0').val()) {
alert('Packaging number can not be greater than Quantity of product')
}
});
 
0
Photo of Ranjit Powar
NA 8.1k 496.8k 9y
If your problem solved, then select it as correct answer. So other users with same problem no which is correct answer.
0
Photo of parul jain
NA 140 10.4k 9y
thank you so much sir.. :) :)
its working... 
0
Photo of Ranjit Powar
NA 8.1k 496.8k 9y
$('#TextBox2').blur(function(){
if($('#TextBox2').val()>$('#TextBox2').val()
{
//Give error message here 
}
});
0
Photo of parul jain
NA 140 10.4k 9y
yeah sir exactly..
0
Photo of Ranjit Powar
NA 8.1k 496.8k 9y
You mean to say when you enter value in textboxt2 right??
0
Photo of parul jain
NA 140 10.4k 9y
yes sir i can..
actually i want restriction that if we are enter some value in textbox1 so in textbox2 must have the value that will be less than or equal to the value of textbox1... 
0
Photo of Ranjit Powar
NA 8.1k 496.8k 9y
can you explain. It gives same value in textbox2
0
Photo of parul jain
NA 140 10.4k 9y
thank you ranjit sir its working..
but in textbox 2 i want the value which is less than or equal to textbox 1..plz give solution becoz i am new in jquery 
0
Photo of Shubham Kumar
NA 6.5k 260.7k 9y
hi try this:
 
 
<asp:TextBox runat="server" id="textbox1" onblur="SetTextInTextBox2()" />
<asp:TextBox runat="server" id="textbox2" onfocus="SetTextInTextBox2()" />

in javascript


  1. function SetTextInTextBox2()   
  2. {   
  3. var a=document.getElementById('textbox1').value ;  
  4. var b= document.getElementById('textbox2').value  
  5. if(a>0)     
  6. {  
  7.  document.getElementById('textbox2').value = document.getElementById('textbox1').value;   
  8. }  
  9.