Advertisement

04.01.2008 at 09:44PM PDT, ID: 23288125
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

FileUpload Control Clears Its Contents When Ajax Update Panel is Updating??

Tags: Microsoft, Microsoft Visual Studio 2008, 2008, ASP.NET, Microsoft Windows Internet Explorer 7, AJAX Update Panel, AJAX Update progress, FileUpload Control
Greetings Experts!
I have a problem, I hope I can describe it clearly, it is somewhat annoying and troublesome and weird. Here is what is going on:

On my aspx page, I have two textbox controls and one fileupload control and a button control, when the user click on the "btnsave" button,  the page checks if the textboxes and fileupload are blank or not, if one of them is blank, then the label control associated with this textbox becomes visible. well, it is quite a long story, I have attached the code for the "btnsave" in the code snippet.

Now the problem is, the contents of the FileUpload control, after the user browse and picks up the a file with the right extention ".zip", and clicks on the "btnsave", the contents of the FileUpload control disappears and the state of "FileUpload1.HasFile" always becomes "False", so, the file uploading never takes place because it seems like as if the user never browsed for a file.

Now this problem happened only when I have placed all the controls on the page inside the "Ajax UpdatePanel", when  the controls are not inside the panel, everything seems to work just fine with the FileUpload control.

I have also attached the html code for the controls inside the UpdatePanel

And the reason why I am useing an Ajax UpdatePanel control is because I need to use the "Ajax UpdateProgress" on my page.

I hope all this makes sense and someone could help me with it, I would really appreciate any kind of help or even directing me into  the right way.

Thanks in advance.

~salman~
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click
 
 
        System.Threading.Thread.Sleep(5000)
 
 
        Dim mybyte() As Byte
        ReDim mybyte(0)
        mybyte(0) = 34
 
        Dim strTitle As String = txtTitle.Text
        If (strTitle.IndexOf("\") > -1) Or (strTitle.IndexOf("/") > -1) Or (strTitle.IndexOf("<") > -1) Or _
           (strTitle.IndexOf(">") > -1) Or (strTitle.IndexOf("*") > -1) Or (strTitle.IndexOf("|") > -1) Or _
           (strTitle.IndexOf("?") > -1) Or (strTitle.IndexOf(":") > -1) Or (strTitle.IndexOf(ASCIIEncoding.ASCII.GetString(mybyte)) > -1) Then
 
 
            lblTitleError.Text = "J,( 'F JCHF 'D9FH'F E*CHF EF '1B'E H -1HA AB7"
            lblTitleError.Visible = True
            lbldescriptionError.Visible = False
            lblUploadError.Visible = False
 
        ElseIf (txtTitle.Text = "") Then
            lblTitleError.Text = "J,( 'F *69 9FH'F 'DC*'("
            lblTitleError.Visible = True
            lbldescriptionError.Visible = False
            lblUploadError.Visible = False
 
        ElseIf (txtDescription.Text = "") Then
            lbldescriptionError.Visible = True
            lblTitleError.Visible = False
            lblUploadError.Visible = False
 
        ElseIf Not (FileUpload1.HasFile) Then
            lblUploadError.Text = "J,( 'F *.*'1 EDA 'DC*'("
            lblUploadError.Visible = True
            lbldescriptionError.Visible = False
            lblTitleError.Visible = False
        Else
 
            lblUploadError.Visible = False
            lbldescriptionError.Visible = False
            lblTitleError.Visible = False
 
 
            If (FileUpload1.HasFile = True) Then
                Dim fileExt As String
                fileExt = System.IO.Path.GetExtension(FileUpload1.FileName)
 
 
                If (fileExt = ".zip") Then
 
                    Dim titleExists As Boolean = False
                    Using myconn As New OleDbConnection(ConfigurationManager.ConnectionStrings("MasterDataFile").ConnectionString)
                        myconn.Open()
                        Using command1 As New OleDbCommand("select title from Books where title = '" & txtTitle.Text & "'", myconn)
                            command1.CommandType = CommandType.Text
                            Dim myreader As OleDbDataReader
                            myreader = command1.ExecuteReader
                            If (myreader.HasRows) Then
                                titleExists = True
                            End If
                        End Using
                        If (titleExists = True) Then
                            lblTitleError.Text = "'D9FH'F 'D0J '.*1*G E*C11 AJ B'9/) 'D(J'F'*, '.*1 9FH'F '.1"
                            lblTitleError.Visible = True
 
                        Else
                            lblTitleError.Visible = False
                            btnSave.Enabled = False
 
                            Try
                                FileUpload1.SaveAs("D:\project(2-4-2008)\Data\Books\" & txtTitle.Text & ".zip")
                                lblUploadError.Text = "File name: " & _
                                  FileUpload1.PostedFile.FileName & "<br>" & _
                                  "File Size: " & _
                                  FileUpload1.PostedFile.ContentLength & " kb<br>" & _
                                  "Content type: " & _
                                  FileUpload1.PostedFile.ContentType
 
                                Dim fileName As String = "D:\project(2-4-2008)\Data\Books\" & txtTitle.Text & ".zip"
 
                                Using mycommand As New OleDbCommand("insert into Books(title, description, file_name) values('" & txtTitle.Text & "','" & txtDescription.Text & "','" & fileName & "')", myconn)
 
                                    mycommand.CommandType = CommandType.Text
                                    mycommand.ExecuteNonQuery()
 
 
                                End Using
                                Server.Transfer("AddNewBookSuccess.aspx", False)
                            Catch ex As Exception
                                lblUploadError.Text = "ERROR: " & ex.Message.ToString()
                                lblUploadError.Visible = True
                            End Try
 
 
                        End If
 
                    End Using
 
 
                Else
                    lbldescriptionError.Visible = False
                    lblTitleError.Visible = False
                    lblUploadError.Text = "Only .zip files allowed!"
                    lblUploadError.Visible = True
                End If
 
            End If
 
 
 
 
 
        End If
    End Sub
-----------------------------------------------------------------
here is the html code:
---------------------------------------------------
<asp:Content ID="Content1" ContentPlaceHolderID="BooksChildPlaceHolder" Runat="Server">
     <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
 
     
     <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate >
     <table width="100%">
   
    
    <tr>
    <td colspan = "2" align = "center">
      
    <asp:Label ID="lblHeader" runat = "server" Font-Size="X-Large" 
            Font-Underline="True" >'6'A) C*'( ,/J/</asp:Label>
        <br />
        <br />
    </td>
    
    </tr>
  
 
 
  
<tr>
<td  align="center">
 
<asp:Label id= "lblTitleError" runat = "server" 
        Text="J,( 'F JCHF 'D9FH'F E*CHF EF '1B'E H -1HA AB7" Visible = "False" 
        BackColor="Yellow" Font-Size="Large" Width="100%" ></asp:Label>
 
    <br />
<asp:TextBox ID="txtTitle" runat = "server" MaxLength="255" Width="100%" 
        CssClass="TextStyle"></asp:TextBox>
<br />
 
</td>
<td align="center">
<asp:Label ID="label1" runat ="server" Font-Size="Large" >9FH'F 'DC*'(</asp:Label>
</td>
</tr>
 
 
 
<tr>
<td align="center">
 
<asp:Label id= "lbldescriptionError" runat = "server" 
        Text="J,( 'F *69 E.*51 DDC*'( B(D 9EDJ) 'D-A8" Visible = "False" 
        BackColor="Yellow" Font-Size="Large" Width="700px" ></asp:Label>
 
    <br />
<asp:TextBox ID="txtDescription" runat = "server" MaxLength="255" Width="700px" 
        CssClass="TextStyle" Height="69px" TextMode="MultiLine" ></asp:TextBox>
</td>
<td align="center" >
<asp:Label id="label2" runat = "server" Font-Size="Large">E.*51 'DC*'(</asp:Label>
 
</td>
</tr>
 
 
<tr>
<td  align="center" colspan = "2">
 
<asp:Label id= "lblUploadError" runat = "server" Visible = "False" 
        BackColor="Yellow" Font-Size="Large" Width="100%" ></asp:Label>
 
    <br />
    <asp:FileUpload ID="FileUpload1" runat="server" Font-Size="Large" EnableViewState = "true"   />
 
</td> 
 
</tr>
 
 
<tr>
<td  align="center" colspan = "2">
 
    <br />
     
  
  <asp:Button   ID="btnSave" runat="server" Font-Size="Large" Text="-A8 'DC*'("  />
 
<br />
 
 
 
     
    
          
  
 
</td> 
 
 
 
 
</tr>
 
 
 
</table> 
 
 </ContentTemplate>
    </asp:UpdatePanel>
 
     
 
  
  <table width = "100%">
  <tr>
  <td align = "center" >
  <asp:UpdateProgress ID="UpdateProgress1" runat="server"  >
      <ProgressTemplate>
      <br /><br />
      <asp:Image ID="myimage" runat = "server" ImageUrl ="~/images/progress.gif" 
              Height="61px" Width="67px" />
      <br />
      <br />
      <asp:Label ID="mylabel" runat = "server" Text="Processing Request.........." 
              Font-Size="X-Large"></asp:Label>
      
 </ProgressTemplate>
  </asp:UpdateProgress>
  </td>
  </tr>
  
  </table>
 
 
 
  
</asp:Content>
Start your free trial to view this solution
Question Stats
Zone: Web Development
Question Asked By: salman_sulaiman_2008
Solution Provided By: emoreau
Participating Experts: 1
Solution Grade: A
Views: 148
Translate:
Loading Advertisement...
04.02.2008 at 02:59AM PDT, ID: 21261424

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.02.2008 at 06:37PM PDT, ID: 21269142

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.03.2008 at 02:43AM PDT, ID: 21270835

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.03.2008 at 06:52AM PDT, ID: 21272633

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.06.2008 at 11:52AM PDT, ID: 21292740

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.06.2008 at 01:40PM PDT, ID: 21293078

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.06.2008 at 08:39PM PDT, ID: 21294202

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.06.2008 at 08:42PM PDT, ID: 21294210

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.08.2008 at 06:08AM PDT, ID: 21304774

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.08.2008 at 04:01PM PDT, ID: 21310407

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
20080236-EE-VQP-29 / EE_QW_2_20070628