【发布时间】:2013-08-06 01:32:01
【问题描述】:
我正在尝试为需要复杂验证处理的表单创建渲染模板。 渲染模板工作正常:
<XmlDocuments>
<XmlDocument NamespaceURI="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms">
<FormTemplates xmlns="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms">
<Display>ListForm</Display>
<Edit>ChaisTemplate</Edit>
<New>ChaisTemplate</New>
</FormTemplates>
</XmlDocument>
</XmlDocuments>
和我的 ascx :
<%@ Control AutoEventWireup="true" CodeBehind="ChaisTemplate.ascx.cs"
Inherits="TransactionsFormsTemplates.ControlTemplates.ChaisTemplate, TransactionsFormsTemplates"
Language="C#" %>
<%@ Assembly Name="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="SharePoint" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"
Namespace="Microsoft.SharePoint.WebControls" %>
<%@ Register TagPrefix="wssuc" TagName="ToolBar" Src="~/_controltemplates/ToolBar.ascx" %>
<%PageLoad(this, null);%>
<SharePoint:RenderingTemplate ID="ChaisTemplate" runat="server">
.....
但我的代码中没有任何控制映射(在带有 cas 策略的 webapp bin 中,并且已正确部署) 这个:
<asp:TextBox runat="server" ID="test"></asp:TextBox>
当涉及到时为空:
public partial class ChaisTemplate : System.Web.UI.UserControl
{
protected TextBox test;
所以每次我在函数上调用 test.Text 时,我都会得到一个 nullreferenceexception,因为 test 从未映射到我的 ascx 文本框。为什么 ? 另外,PageLoad 永远不会像在经典的 asp.net 页面中那样被调用,即使在开头使用 也是如此。 但是每个事件都有效:
<asp:Button runat="server" ID="button" OnClick="button_OnClick"/>
这实际上会在我后面的代码中调用 button_OnClick。但是我所有的属性都是空的,因为没有映射。
我错过了什么吗?
【问题讨论】:
标签: asp.net forms sharepoint sharepoint-2010 code-behind