r_mason101
asked on
IE vs Firefox image validation
Hi,
I'm using VB.NET to develop a web app which allows user to upload images however client side validation works with IE but not Firefox. Now I am trying to validate based on browser type but it does not work either. Any ideas?
<TR>
<TD><SPAN class="infotext">Picture:< /SPAN></TD >
<TD colSpan="3"><INPUT id="uplPic" type="file" name="uplPic" runat="server">
<%if not(Request.Browser.Browse r.Equals(" IE")) then%>
<!--this regular experssion works in firefox only-->
<asp:regularexpressionvali dator id="revUpPic" runat="server" ControlToValidate="uplPic" ErrorMessage="MOZ Picture must be a .JPG or .GIF" ValidationExpression="^[0- 9A-Za-z_ ]+(.[jJ][pP][gG]|.[gG][iI] [fF])$" Font-Bold="True" Font-Size="Medium">*</asp: regularexp ressionval idator></T D>
<%else if (Request.Browser.Browser.E quals("IE" )) then %>
<!--this regular experssion works in IE only-->
<asp:regularexpressionvali dator id="revUpPic1" runat="server" ControlToValidate="uplPic" ErrorMessage="IE Picture must be a .JPG or .GIF"
ValidationExpression="^(([ a-zA-Z]:)| (\\{2}\w+) \$?)(\\(\w [\w].*))+( .gif|.GIF| .jpg|.JPG| .jpeg|.JPE G)$" Font-Bold="True" Font-Size="Medium">*</asp: regularexp ressionval idator></T D>
<%end if%>
</TR>
Thanks.
I'm using VB.NET to develop a web app which allows user to upload images however client side validation works with IE but not Firefox. Now I am trying to validate based on browser type but it does not work either. Any ideas?
<TR>
<TD><SPAN class="infotext">Picture:<
<TD colSpan="3"><INPUT id="uplPic" type="file" name="uplPic" runat="server">
<%if not(Request.Browser.Browse
<!--this regular experssion works in firefox only-->
<asp:regularexpressionvali
<%else if (Request.Browser.Browser.E
<!--this regular experssion works in IE only-->
<asp:regularexpressionvali
ValidationExpression="^(([
<%end if%>
</TR>
Thanks.
the problem is that client side validation is done in javascript in the browser. you should load the page with firefox and look for any javascript errors it gives, and also look at the page source and find the validation javascript. are you sure that your if else statement is always putting a validator in the rendered page?
ASKER
thanks.
the if statement does not work, it tries to perform both sets of validation. I did not see any javascript errors in firefox. What is the simpilest way to implement validtion for the extension thats works in any browser, is it client or server side code?
this is the code i am using for uploading images, can i add some validation somewhere in here?
Dim strImageName As String
strImageName = "com" & nCommercialID & "A.jpg"
Dim strPath As String = Server.MapPath("/WantMyLea se/commerc ialImage")
'If ("" = strImageName) Then
'lblMemberID.Text = "Error - a file name must be specified."
'End If
If Not (uplPic.PostedFile.FileNam e = "") Then
Try
uplPic.PostedFile.SaveAs(s trPath + "/" + strImageName)
lblMemberID.Text = Server.MapPath("/commercia lImage")
generateThumbnail(strImage Name)
Catch ext As Exception
lblMemberID.Text = "Error saving <b>" & strPath & strImageName & "</b><br>" & ext.ToString()
' Return False
End Try
End If
Thanks for your help.
the if statement does not work, it tries to perform both sets of validation. I did not see any javascript errors in firefox. What is the simpilest way to implement validtion for the extension thats works in any browser, is it client or server side code?
this is the code i am using for uploading images, can i add some validation somewhere in here?
Dim strImageName As String
strImageName = "com" & nCommercialID & "A.jpg"
Dim strPath As String = Server.MapPath("/WantMyLea
'If ("" = strImageName) Then
'lblMemberID.Text = "Error - a file name must be specified."
'End If
If Not (uplPic.PostedFile.FileNam
Try
uplPic.PostedFile.SaveAs(s
lblMemberID.Text = Server.MapPath("/commercia
generateThumbnail(strImage
Catch ext As Exception
lblMemberID.Text = "Error saving <b>" & strPath & strImageName & "</b><br>" & ext.ToString()
' Return False
End Try
End If
Thanks for your help.
If validation happens when you tab out of the field then the validation is done with client-side script ASP.NET has
generated. And ASP.NET 1.1 usually generates client-side script geared
towards IE 4 and later using the IE DOM and not the more cross browser
compatible W3C DOM, therefore with the normal settings browsers like
Mozilla, firefox will not get that client-side script at all. Server-side
validation on postback should nevertheless work independent of the
browser and any client-side script ASP.NET might or might not generate.
try using IsValid.
generated. And ASP.NET 1.1 usually generates client-side script geared
towards IE 4 and later using the IE DOM and not the more cross browser
compatible W3C DOM, therefore with the normal settings browsers like
Mozilla, firefox will not get that client-side script at all. Server-side
validation on postback should nevertheless work independent of the
browser and any client-side script ASP.NET might or might not generate.
try using IsValid.
ASKER
can i get server side code to perform validation? BTW i am using Page.IsValid
Thanks.
Thanks.
try ErrorMsg_ServerValidate function from this code: http://www.codeproject.com/useritems/Custom_File_Upload.asp
ASKER
thanks but i need vb.net code, i am not familiar with c#
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.