문제

I am creating a custom form template for a list and this form template uses a lot of controls such as panels and dropdowns. I am using a rendering template in the controltemplates folder and have this working. I want to now add code-behind to the control template and I can not seem to find an example of how to do this correctly. I am using VSeWSS 1.3 and VS 2008 and have my solution all setup. I just want to know how to setup a code-behind page for this template.

도움이 되었습니까?

해결책

Just build (and sign) your code beforehand, drop it in the bin_app_bin and drop the class declaration in the <@Control tag.

<%@ Control Language="C#" Inherits="YourNamespace.Class,YourAssembly.AssemblyName,Version=1.0.0.0,Culture=neutral,PublicKeyToken=YourPublicKeyToken" %>

다른 팁

Theres alot of examples of this out there on how to do this.

This was the first example google gave me

http://jamestsai.net/Blog/post/Using-ASPNET-Web-User-Control-with-Code-Behind-in-SharePoint.aspx

As I was not successful in getting this to work right, I tried to understand if I really had to do it the way I was doing it. As it turns out, I was able to instead build a custom webpart and put my controls in there and then just used a different page for the new and edit forms. Not sure if this will really help anyone else it is just what I did to get the job done.

I'm having the same problem as the OP also. I would like to here more from John Dandison if you're still listening!

I've added the inherits attribute with the 5 part name to the CONTROL directive. My code behind class looks like this.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;

namespace MyNamespace
{
    public class CustomRenderingTemplate : UserControl
    {
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
        }
    }
}

The rendering template is loading ok. I've added a break point to the 2 overriden methods and neither is being hit so I'm assuming it's not wired up ok? Can you help me out? Am I inheriting from the correct class - UserControl?

http://www.andrewconnell.com/blog/articles/UsingCodeBehindFilesInSharePointSites.aspx

I don't use the VSeWSS, but the process is the same. You need to get the 5-part name of the code behind and wire it up in the ASPX's Inherits attribute in the Page directive.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 sharepoint.stackexchange
scroll top