I'm trying to use a .NET User Control Macro in Umbraco 6.0.6 editor, but using a formview control I can't get access to controls inside it on page_load event.
Ex:
ASCX:
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="teste.ascx.vb" Inherits="usercontrols_teste" %>
<asp:FormView ID="FormView1" runat="server" DefaultMode="Insert">
<InsertItemTemplate>
<asp:TextBox ID="txt_name" runat="server"></asp:TextBox>
</InsertItemTemplate>
</asp:FormView>
CODE-FILE:
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
FormView1.DefaultMode = FormViewMode.Insert
CType(FormView1.FindControl("txt_name"), TextBox).Text = "name"
End Sub
MasterPage Template:
<form id="form1" runat="server">
<umbraco:Item ID="Item1" field="conteudoPagina" runat="server"></umbraco:Item>
</form>
The result is an "Object reference not set to an instance of an object." on the line: CType(FormView1.FindControl("txt_name"), TextBox).Text = "name"
This only happens when the control is rendered from the umbraco editor, if I use the control normally in a web page or masterpage it works ok.
Anyone with the same results?
thanks