简体   繁体   English

更新面板无法正常工作

[英]Update Panel not working properly

I have a read-only TextBox and an Edit button. 我有一个只读的TextBox和一个Edit按钮。 When I click the button the textbox should be readable and the Save button should appear. 当我单击按钮时, textbox应该可读,并且应该显示“保存”按钮。 This happens perfectly, but the whole page is reloading all the time. 这种情况发生得很完美,但是整个页面一直都在重新加载。 I have used an UpdatePanel but nothing happened. 我使用了UpdatePanel但是什么也没发生。 Can someone help me to solve my problem please? 有人可以帮我解决我的问题吗? Thanks in advance. 提前致谢。

ASPX : ASPX

 <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server" updatemode="Conditional">
            <Triggers>
            <asp:AsyncPostBackTrigger controlid="edit" eventname="Click" />
            </Triggers>
            <ContentTemplate>

                   <asp:TextBox ID="q" runat="server" ReadOnly style="width:90%" 
                       BackColor="#CCCCCC" BorderStyle="None" Rows="5" TextMode="MultiLine"></asp:TextBox>
                   <asp:Button ID="edit" class="button3"  style="float:right"  
                       runat="server" Text="Edit" onclick="editqellim_Click"  />
                    <asp:Button ID="save"  class="button3"  style="float:right" runat="server" 
                       Text="Save" onclick="Button1_Click" Visible="False" />
                 </ContentTemplate>
                </asp:UpdatePanel>

code behind : 后面的代码

protected void editqellim_Click(object sender, EventArgs e)
    {
        q.ReadOnly = false;
        q.BackColor = Color.White;
        save.Visible = true;

    }

I'd bet there's a bad javascript error on the page which is breaking Microsoft's javascript for the UpdatePanel. 我敢打赌页面上有一个错误的javascript错误,它破坏了Microsoft的UpdatePanel javascript。 If you load the page with the developer console showing, do you get any javascript errors immediately on loading? 如果在显示开发人员控制台的情况下加载页面,加载时是否会立即遇到任何JavaScript错误? Maybe something that kills javascript on the page? 也许某些东西会杀死页面上的javascript? Or any javascript errors as you click the button? 或点击按钮时出现任何JavaScript错误?

If so, I bet that error is killing the AJAX stuff, leaving the button as a regular submit button, which submits the form like it would without the UpdatePanel. 如果是这样,我敢打赌这个错误会杀死AJAX内容,将按钮保留为常规的提交按钮,就像没有UpdatePanel一样提交表单。

UpdateMode="Conditional"更改为UpdateMode="Always"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM