0

我有一个不工作的更新面板。我的整个代码:

<%@ Page Language="C#" MasterPageFile="~/Master.Master" AutoEventWireup="true" CodeBehind="AlgemeenDocument.aspx.cs" Inherits="PCK_Web_new.WebForm7" Title="Untitled Page" %>

<asp:ScriptManager ID="ScriptManager1" runat="server" />

<script language="javascript" type="text/javascript">

    function showOverlay(panel)
    {
        var pageHeight;

        // Get viewport height
        if (typeof window.innerWidth != 'undefined')
            // Get viewport height - FF
            vpHeight = window.innerHeight;
        else
            // Get viewport height - IE
            vpHeight = document.documentElement.clientHeight;

        // Get site height (div)

        var treeview = document.getElementById("Treeview");
        var siteHeight = 0;

        if(treeview != null)
        {
            siteHeight = document.getElementById("Treeview").offsetHeight;
        }
        siteHeight += document.getElementById("HeaderContainer").offsetHeight;
        siteHeight += document.getElementById("divMainMenu").offsetHeight;



        // Compare heights and set the overlay height
        if(vpHeight < siteHeight)
            pageHeight = siteHeight + "px";
        else
            pageHeight = vpHeight + "px";


        var div = document.getElementById(panel);

        div.className = "DocOverlayShow";
        div.style.height = pageHeight;

        document.getElementById('<%= pnlAddComment.ClientID %>').className="DocAddCommentBox";
    }

    function hideOverlay()
    {
        //document.getElementById(commentID).style.visibility = "hidden";
        //document.getElementById(titelID).style.visibility = "hidden";

        var inputs = new Array();
        inputs = document.getElementsByTagName('input'); 

        for ( i = 0; i < inputs.length; i++ )
        { 
            if ( inputs[i].type == 'text' )
            {
                inputs[i].value = '';
            }
        }     

        document.getElementById('<%= txtTitel.ClientID %>').value = "";
        document.getElementById('<%= txtComment.ClientID %>').value = "";

        document.getElementById('<%= pnlOverlay.ClientID %>').className = "DocOverlayHide";
    }

</script>


    <asp:Panel ID="pnlOverlay" runat="server" CssClass="DocOverlayHide">

        <!-- <div id="DocAddCommentBox"> -->
        <asp:Panel ID="pnlAddComment" runat="server" CssClass="DocAddCommentBox">

            <div id="DocACTitleBox">
                Opmerking plaatsen
            </div>

            <div id="DocACContentBox">
                <div class="DocACLabel">
                    Titel:
                </div>
                <div class="DocACInput">
                    <asp:TextBox ID="txtTitel" runat="server"></asp:TextBox>
                </div>
                <div class="ClearFloat">



                </div>
                <div class="DocACLabel">
                    Opmerking:
                </div>
                <div class="DocACInput">
                    <asp:TextBox ID="txtComment" runat="server" TextMode="MultiLine" Rows="15" 
                        Columns="40">
                    </asp:TextBox>
                </div>
                <div class="ClearFloat">



                </div>
                <div id="DocBtnBox">
                    <input id="btnCancel" type="button" onclick="hideOverlay()" value="Annuleren"/>


                    <asp:UpdatePanel ID="UpdatePanel2" runat="server" EnableViewState="False" UpdateMode="Always" RenderMode="Block">
                    <ContentTemplate>
                        <asp:Button ID="btnSave" runat="server" CssClass="btnSave" onclick="btnSave_Click" Text="Opslaan" />
                        <asp:Label ID="lblTitleError" runat="server" Text="ertroro"></asp:Label>
                    </ContentTemplate>
                    </asp:UpdatePanel>


                </div>
                <div class="ClearFloat">&nbsp;</div>
            </div>

        </asp:Panel>
        <!-- </div> -->


        <asp:Panel ID="pnlResult" runat="server" CssClass="DocOverlayHide">

            <div id="DocResultBox">
                <div id="Div1">
                    Opmerking plaatsen
                </div>

                <div id="Div2">
                    <div class="DocACLabel">
                        <asp:Label ID="lblResult" runat="server" Text="Label"></asp:Label>
                    </div>

                    <div id="Div1">
                        <input id="btnClose" type="button" onclick="hideOverlay()" value="Sluiten"/> 
                    </div>
                    <div class="ClearFloat">&nbsp;</div>
                </div>
            </div>

        </asp:Panel>

</asp:Panel>



<div class="DocContainer">

    <div class="DocTitleBox">

        <div class="DocLogo">
            Het logo
        </div>

        <div class="DocTitle">
            <asp:Label ID="lblTitle" runat="server"></asp:Label>
        </div>

        <div class="DocType">
            Document soort
            <asp:Label ID="lblDocType" runat="server"></asp:Label>    
        </div>

        <div class="DocBtn">
            <input type="button" value="Opmerking" onclick="showOverlay('<%=pnlOverlay.ClientID %>')" />
        </div>
    </div>

    <div class="DocContentBox">

        <asp:Label ID="lblID" runat="server"></asp:Label>

        <p>Algemeen Document Geen vaste opmaak.</p>

    </div>

</div>

我试过触发器,但他们没有工作..

当我按 btnSave 这是执行的代码:

    protected void btnSave_Click(object sender, EventArgs e)
    {

        lblTitleError.Text = "BUTTON PRESSED";

    }

当我设置断点时,它会运行代码。但未设置标签文本:S

希望有人可以帮忙?

谢谢!

编辑:

我也试过这个:

<div id="DocBtnBox">
                    <input id="btnCancel" type="button" onclick="hideOverlay()" value="Annuleren"/>

                    <asp:Button ID="btnSave" runat="server" CssClass="btnSave" onclick="btnSave_Click" Text="Opslaan" />

                    <asp:UpdatePanel ID="UpdatePanel2" runat="server" EnableViewState="False" UpdateMode="Always">
                    <ContentTemplate>
                        <asp:Label ID="lblTitleError" runat="server" Text="ertroro"></asp:Label>
                    </ContentTemplate>
                        <Triggers>
                            <asp:AsyncPostBackTrigger ControlID="btnSave" EventName="Click" />
                        </Triggers>
                    </asp:UpdatePanel>

                </div>
4

3 回答 3

1

我认为网络上最好的导师是 Joe Stagner。他的 .NET 材料很棒。

这是一个链接,他在其中准确地向您展示了如何一步一步地做您正在尝试的事情。

附录:

如果我是你,我会根据 Joe 提供的示例代码创建一个干净的页面。转至http://www.asp.net/LEARN/ajax-videos/并找出您想要基于哪个教程来解决您的解决方案。在您在示例页面上获得教程后,我会慢慢地,逐个添加您的应用程序所需的逻辑。

于 2009-01-20T10:13:26.433 回答
0

您希望设置其文本的标签和 btnSave 按钮元素都应位于更新面板元素内。

于 2009-01-20T10:12:12.270 回答
0

尝试从 UpdatePanel 中删除 EnableViewState="False"。

于 2009-01-23T11:06:58.257 回答