Hi,
I ran into a strange problem while trying to validate a HtmlInputFile 
control.
The situation is this:
I have a HtmlInputFile Control in the EditItemTemplate of a DataList 
with an ID and Runat="server" and a CustomValidator next to it like 
this:

<asp:datalist id="DataLst" Runat="server" 
OnEditCommand="DataLst_EditCmd">
<EditItemTemplate>
   <table>
      <tr><td>......</td></tr>
      <tr><td>

        <input Type="file" ID="PicUpld" Runat="Server" />
        <asp:CustomValidator ControlToValidate="PicUpld" 
           ErrorMessage="Invalid Format" ID="PicUpldVal"
           Runat="server" OnServerValidate="PicUpldVal_SrvrValidate">
        </asp:CustomValidator>
         
   </table>
</EditItemTemplate>
<ItemTemplate>
   ...............
</ItemTemplate>
</asp:datalist>

Now in my code behind class the only thing I want to validate is that 
either the HtmlInputFile was left empty or a JPEG file was selected, 
so I have the following code:


protected void PicUpldVal_SrvrValidate(Object source, 
ServerValidateEventArgs args)
{
   if (this.PicUpld.Value.Trim().Equals("")) 
   {
      args.IsValid      =       true;
   }
   else 
   {
      args.IsValid      =       this.PicUpld.Value.ToLower().EndsWith
(".jpg") || this.PicUpld.Value..ToLower().EndsWith(".jpeg");
   }
}

THE PROBLEM IS: That when this method is called PicUpld is null, so 
this throws an exception.....

What Am I missing??


Thanks in advance for your help


Victor.








 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to