Anthem Bug:当页面同时出现Anthem.FileUpload和TextArea时callback出错(BADRESPONSE)

出错情况

  1. 页面放Anthem.FileUpload,TextArea(Anthem.TextBox),Anthem.Button.用户先选择了一个文件(没有选择文件不存在后面的问题),然后再点击Button时,在点击事件里改变TextArea的Text值并设置UpdateAfterCallBack为true.callback失败,提示BADRESPONSE.

             前台:
                <anthem:FileUpload ID="FileUpload1" runat="server" />
                <anthem:TextBox ID="TextBox1" runat="server" Height="56px" TextMode="MultiLine" Width="246px"></anthem:TextBox>
                <anthem:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Anthem Upload Button" />
             后台:
                protected void Button1_Click(object sender, EventArgs e)
                {

                        TextBox1.Text = "afdasdfas";
                        TextBox1.UpdateAfterCallBack = true;
                }

  2. 前台代码:

    < table  cellpadding ="0"  cellspacing ="0"  border ="0" >
        
    < tr >
            
    < td  valign ="top" >
                
    < anthem:LinkButton  ID ="lkbtnUploadPhoto"  runat ="server"  Text ="上传头像"  CssClass ="TabLink"
                    OnCommand
    ="lkbtnTab_Click"  CommandArgument ="3" ></ anthem:LinkButton >
            
    </ td >
            
    < td  valign ="top" >
                
    < anthem:LinkButton  ID ="lkbtnSignature"  PreCallBackFunction ="ResetForms"  runat ="server"  Text ="个性签名"  CssClass ="TabLink"
                    OnCommand
    ="lkbtnTab_Click"  CommandArgument ="4" ></ anthem:LinkButton >
            
    </ td >
        
    </ tr >
    </ table >
    < anthem:MultiView  ID ="MultiViewMenu"  runat ="server" >
            
    < anthem:View  ID ="viewUploadPhoto"  runat ="server" >
            
    < table >
                
    < tr >
                    
    < td  style ="width: 211px" >
                        
    < asp:Label  ID ="Label10"  runat ="server"  Text ="当前头像" ></ asp:Label >
                    
    </ td >
                    
    < td >
                    
    </ td >
                
    </ tr >
                
    < tr >
                    
    < td  style ="width: 211px" >
                        
    < anthem:Image  ID ="imgCurrentPhoto"  runat ="server"   /></ td >
                    
    < td >
                    
    </ td >
                
    </ tr >
                
    < tr >
                    
    < td  style ="width: 211px" >
                        
    < asp:Label  ID ="Label11"  runat ="server"  Text ="从电脑中选择一幅新头像照片" ></ asp:Label >
                    
    </ td >
                    
    < td >
                        
    < input  type ="button"  id ="btnSelectPhoto"  onclick ="FileUpload_Click();"  value ="选择"   /></ td >
                
    </ tr >
                
    < tr >
                    
    < td  rowspan ="5"  style ="width: 211px" >
                        
    < anthem:Image  ID ="imgUploadImage"  runat ="server"   /></ td >
                    
    < td >
                        
    < asp:FileUpload  ID ="PhotoFileUpload"  runat ="server"   /></ td >
                
    </ tr >
                
    < tr >
                    
    < td  style ="height: 21px" >
                        
    < anthem:TextBox  ID ="txtSelectUrl"  ReadOnly ="true"  runat ="server" ></ anthem:TextBox >
                    
    </ td >
                
    </ tr >
                
    < tr >
                    
    < td >
                    
    </ td >
                
    </ tr >
                
    < tr >
                    
    < td  style ="height: 21px" >
                        
    < anthem:Button  ID ="btnUpload"  runat ="server"  Text ="确认上传"   />
                        
    < anthem:Button  ID ="btnUplaodCancel"  runat ="server"  Text ="放弃"   /></ td >
                
    </ tr >
                
    < tr >
                    
    < td >
                    
    </ td >
                
    </ tr >
                
    < tr >
                    
    < td  rowspan ="1"  style ="width: 211px" >
                    
    </ td >
                    
    < td >
                    
    </ td >
                
    </ tr >
                
    < tr >
                    
    < td  style ="width: 211px" >
                        
    < asp:Label  ID ="Label12"  runat ="server"  Text ="从相册中选择一幅照片" ></ asp:Label >
                    
    </ td >
                    
    < td >
                        
    < anthem:Button  ID ="btnSelectServerPhoto"  runat ="server"  Text ="选择"   /></ td >
                
    </ tr >
                
    < tr >
                    
    < td  rowspan ="4"  style ="width: 211px" >
                        
    < anthem:Image  ID ="imgPhoto"  runat ="server"   /></ td >
                    
    < td >
                    
    </ td >
                
    </ tr >
                
    < tr >
                    
    < td  style ="height: 21px" >
                        
    < anthem:TextBox  ID ="txtPhotoUrl"  ReadOnly ="true"  runat ="server" ></ anthem:TextBox ></ td >
                
    </ tr >
                
    < tr >
                    
    < td >
                    
    </ td >
                
    </ tr >
                
    < tr >
                    
    < td  style ="height: 21px" >
                        
    < anthem:Button  ID ="btnOnlineEdit"  runat ="server"  Text ="在线编辑"   /></ td >
                
    </ tr >
                
    < tr >
                    
    < td  rowspan ="1"  style ="width: 211px" >
                    
    </ td >
                    
    < td  style ="height: 21px" >
                    
    </ td >
                
    </ tr >
            
    </ table >
        
    </ anthem:View >
        
    < anthem:View  ID ="viewSignature"  runat ="server" >
            
    < table >
                
    < tr >
                    
    < td  valign ="top" >
                        
    < asp:Label  ID ="lblSignature"  runat ="server"  Text ="个性签名" ></ asp:Label >
                    
    </ td >
                    
    < td >
                        
    < anthem:TextBox  ID ="txtSignature"  TextMode ="multiLine"  runat ="server"  Height ="171px"
                            Width
    ="335px" ></ anthem:TextBox >
                    
    </ td >
                
    </ tr >
            
    </ table >
        
    </ anthem:View >
      
    </ anthem:MultiView >
    < table >
        
    < tr >
            
    < td >
                
    < anthem:Button  ID ="btnUpdate"  runat ="server"  OnClick ="btnUpdate_Click"  Text ="保存修改"   />
            
    </ td >
            
    < td >
                
    < anthem:Button  ID ="btnCancel"  runat ="server"  OnClick ="btnCancel_Click"  Text ="取消"   />
            
    </ td >
        
    </ tr >
    </ table >

            后台代码:
            

 1      Tab Link Event
15
16      Custom Event

目前针对以上两种情况,我的解决办法是添加Button的PreCallBackFunction="ResetForms"(红色部分)
function  ResetForms()
    
{
        
var fileUpload = document.getElementById("<%=PhotoFileUpload.ClientID %>");
        
if(fileUpload!=null && fileUpload.value!="")
        
{
            document.forms[
0].reset();
        }

    }

其实就是刷新form.不知道还有没有更好的解决办法.

你可能感兴趣的:(fileupload)