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 #region Tab Link Event
 2    /**//// <summary>
 3    /// Navigates to the Tab
 4    /// </summary>
 5    /// <param name="sender">sender</param>
 6    /// <param name="e">EventArgs</param>

 7    protected void lkbtnTab_Click(object sender, CommandEventArgs e)
 8    {
 9        ActiveViewIndex = Convert.ToInt16(e.CommandArgument.ToString());
10        SetTabDefaultCss();
11        ShowViewByTabId(ActiveViewIndex);
12        MultiViewMenu.UpdateAfterCallBack = true;
13    }

14    #endregion

15
16      Custom Event #region Custom Event
17
18    /**//// <summary>
19    /// show view by tab id
20    /// </summary>
21    /// <param name="tabId">the tab id</param>

22    private void ShowViewByTabId(int tabId)
23    {
24        switch (tabId)
25        {
26            case 3:
27                MultiViewMenu.SetActiveView(viewUploadPhoto);
28                lkbtnIntroduction.CssClass = TabSelectedCssName;
29                //PhotoFileUpload.Style.Add("display", "none");
30                btnUpdate.ValidationGroup = "";
31                btnUpdate.PreCallBackFunction = string.Empty;
32                break;
33            case 4:
34                MultiViewMenu.SetActiveView(viewSignature);
35                lkbtnSignature.CssClass = TabSelectedCssName;
36                txtSignature.Text = CurrentUserOtherInfo.Signature;
37                btnUpdate.ValidationGroup = string.Empty;
38                btnUpdate.PreCallBackFunction = string.Empty;
39                break;
40        }

41        btnUpdate.UpdateAfterCallBack = true;
42    }

43
44    /**//// <summary>
45    /// set tab default css class.
46    /// </summary>

47    private void SetTabDefaultCss()
48    {;
49        lkbtnSignature.CssClass = TabDefaultCssName;
50        lkbtnUploadPhoto.CssClass = TabDefaultCssName;
51    }

52
53    #endregion

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

    }

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

转载于:https://www.cnblogs.com/wliang22/archive/2008/07/15/1243576.html

1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看REaDME.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值