Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6540667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:00:24+00:00 2026-05-25T11:00:24+00:00

I’m trying to create a rendering template for my forms which need complex validations

  • 0

I’m trying to create a rendering template for my forms which need complex validations treatments.
the rendering template is working fine wwith :

<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>

and with my 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">

.....

but I can’t have any control mappings in my code behind (in the webapp bin with cas policies, and it’s correctly deployed)
this :

  <asp:TextBox runat="server" ID="test"></asp:TextBox>

is null when it comes to :

 public partial class ChaisTemplate : System.Web.UI.UserControl 
{
    protected TextBox test;

so everytime I call test.Text on functions, I get a nullreferenceexception, because test is never mapped to my ascx textbox. why ?
plus, the PageLoad is never called like in classic asp.net pages, even with <%PageLoad(this, null);%> at the beginning.
however every event works :

 <asp:Button runat="server" ID="button" OnClick="button_OnClick"/>

this will actually call button_OnClick in my code behind. But all my properties are null because not mapped.

did I miss something?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T11:00:25+00:00Added an answer on May 25, 2026 at 11:00 am

    I’v been doing it like this. Take this as an example RenderingTemplate:

    <SharePoint:RenderingTemplate ID="ParentItemsListView" runat="server">
        <Template>
            <table cellpadding=0 cellspacing=0>
                <tr><td nowrap class="UserGenericHeader"><asp:Label ID="lblParentItems" runat="server" /></td></tr>
                <tr><td><SharePoint:ListViewByQuery ID="listViewByQuery" runat="server" /><br /></td></tr>
            </table>
        </Template>
    </SharePoint:RenderingTemplate>
    

    Then in Render event i can reference these controls like this:

        [SharePointPermission(SecurityAction.Demand, ObjectModel = true)]
        protected override void Render(HtmlTextWriter output)
        {
            if (this.Visible)
            {
                Label lblParentItems = this.TemplateContainer.FindControlRecursive<Label>("lblParentItems");
                lblParentItems.Text = "Pievienotie " + this.ChildList.Title;
    
                ListViewByQuery listView = TemplateContainer.FindControlRecursive<ListViewByQuery>("listViewByQuery");
                listView.List = this.ChildList;
                ...
                base.Render(output);
            }
       }
    

    Ahh, yes, i use a handy extension function

    public static T FindControlRecursive<T>(this Control parentControl, string id) where T : Control
    {
        T ctrl = default(T);
    
        if ((parentControl is T) && (parentControl.ID == id))
            return (T)parentControl;
    
        foreach (Control c in parentControl.Controls)
        {
            ctrl = c.FindControlRecursive<T>(id);
    
            if (ctrl != null)
                break;
        }
        return ctrl;
    }
    

    However i had an issue where i inherited from SaveButton that i couldn’t reference a control. In that case i changed so that i inherit from FormControl and i could find my control under this.Controls.

    Also note that you cannot reference controls up until OnLoad event has executed (i.e if you’re in OnLoad function, call base.OnLoad(e) before referencing controls.

    Why is it so? I guess because it’s not like you are having a template and then code behind (working with the same class/object), but it’s more like you are rendering that ascx template in a different class/object file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
I am trying to loop through a bunch of documents I have to put
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.