我有一个不起作用的updatepanel。我的整个代码:
<%@ 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"> </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"> </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
希望有人可以提供帮助吗?
日Thnx!
编辑:
我也试过这个:
<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>
答案 0 :(得分:1)
我认为网络上最好的导师是Joe Stagner。他的.NET材料非常棒。
这是一个link,在那里他向您展示了如何正确地执行您正在尝试的操作。
附录:
如果我是你,我会根据Joe提供的示例代码创建一个干净的页面。转到http://www.asp.net/LEARN/ajax-videos/并找出您希望以解决方案为基础的教程。在让教程处理示例页面之后,我会慢慢地,逐步添加您的应用程序所需的逻辑。
答案 1 :(得分:0)
您希望设置文本的标签和btnSave按钮元素都应位于Update Panel元素内。
答案 2 :(得分:0)
尝试从UpdatePanel中删除EnableViewState =“False”。