views:

34

answers:

0

I want to change textbox in NewForm within custom dll that imported to the page.

I have NewForm and paste there asp textbox and SP formfield (want to change anyone):

<asp:TextBox id="test" runat="server" >Tex</asp:TextBox>

<SharePoint:FormField runat="server" id="ff3_test" ControlMode="New" FieldName="Customer" OnLoad="alert(this)"/>

Then I wrote dll:

public class CurrentUser : WebPart
{
        protected override void OnLoad(EventArgs e)
        {
            //base.OnInit(e);
            TextBox tbox = (TextBox)this.FindControl("test");

            tbox.Text = "trololo";
        }
}

Also I tried to do with Load function after I changed onLoad to:

protected void OnLoad(object sender, EventArgs e)
{
  ...
}

protected override void CreateChildControls()
{
            this.Page.Load += new EventHandler(OnLoad);
            Label lab = new Label();
            lab.Load += new EventHandler(OnLoad);
            lab.Attributes.Add("id", "ipPhone");   
            lab.Text += "fff";
            Controls.Add(lab);         
}

It does not work, the exception appears when I try to change Text property in the textbox.

May be problem with alternative Page_Load function (don't know is in SP something similar to asp.net).

Or may be the problem that I try to change newform field from my dll that work as different webpart.

<WpNs0:CurrentUser runat="server" ID=" .... partorder="1"></WpNs0:CurrentUser>