2012-12-14 7 views
0

여기에 iframe 만있는 Sitefinity 위젯을 작성했습니다. 위젯의를 Page_Load에서 Sitefinity 위젯 오브젝트 참조가 오브젝트의 인스턴스로 설정되지 않았습니다.

<%@ Control Language="C#" AutoEventWireup="True" CodeBehind="ApplicationFrame.ascx.cs" 
Inherits="MyProject.Web.Ui.Customized.EmbeddedApplications.ApplicationFrame" %> 

<iframe runat="server" id="ApplicationIFrame" height="250" width="250" scrolling="no" frameborder="0" seamless="seamless" src=""></iframe> 

나는 서버 측은 iframe의 속성에 액세스 트라이하지만 난 항상 "개체의 인스턴스로 설정되지 않았습니다 개체 참조"를 얻는다.

다음은 C#

namespace MyProject.Web.Ui.Customized.EmbeddedApplications 
{ 
     [ControlDesigner(typeof(ApplicationFrameDesigner))] 
     public partial class ApplicationFrame : System.Web.UI.UserControl 
     { 
      public string FrameSourceUrl {get;set;} 
      public string FrameHeight { get; set; } 
      public string FrameWidth { get; set; } 
      protected void Page_Load(object sender, EventArgs e) 
      { 
       //set the values of the iframe to the current properties 
       ApplicationIFrame.Attributes["src"] = FrameSourceUrl; 
       ApplicationIFrame.Attributes["height"] = FrameHeight; 
       ApplicationIFrame.Attributes["width"] = FrameWidth; 
      } 
     } 
} 

내가 최근에 웹 응용 프로그램을 웹 사이트에서 프로젝트를 변경,하지만 그 어떤 방식으로 프로젝트에 영향을 미칠 것 같았다 않았습니다.

그 외에도 내가 왜이 예외가 계속 발생하는지 알 수 없습니다.

누구든지 문제가 무엇인지 알 수 있습니까?

덕분에, 자크

답변

0

이 당신이 만든 위젯의 종류에 따라 작동하지 않을 수 있습니다. 아마도 일반 사용자 컨트롤에서는 작동하지만 사용자 정의 컨트롤에서는 작동하지 않습니다.

sitefinity 문서를 따르는 중이면 SimpleView에서 상속 할 수 있습니다. 그런 다음 템플릿에서 컨트롤을 가져 오는 도우미 메서드에 액세스 할 수 있습니다. 그래서 대신의 :

ApplicationIFrame.Attributes["src"] = FrameSourceUrl; 

이 작업을 수행 할 수 있습니다

this.GetControl<HtmlControl>("ApplicationIFrame", true).Attributes["src"] = FrameSourceUrl;