If I want to render the InputPageReference control I have to patch the generated code like this example:
//Create a InputPageReference on the fly
EPiServer.WebControls.InputPageReference pref = new EPiServer.WebControls.InputPageReference();
//Setting text value (if not still in view mode, now in edit)
pref.Text = "4";
//Put an id to the control before render
pref.ID = "pref1";
System.Text.StringBuilder result = new System.Text.StringBuilder(1024);
pref.RenderControl(new HtmlTextWriter(new System.IO.StringWriter(result)));
//Patch EPiServers webcontrol! Is this a bug?
result.Replace("document.all['Hidden'].value,'Display','Hidden'", "document.all['" + pref.ID + "$Hidden'].value,'" + pref.ID + "$Display','" + pref.ID + "$Hidden'");
//Set the control, it could be just right to a pages form. In this case inside a webgrid's row event:
e.Row.Columns["Source"].BeforeEditHtml = Server.HtmlEncode(result.ToString()) + result.ToString();
//Create a InputPageReference on the fly EPiServer.WebControls.InputPageReference pref = new EPiServer.WebControls.InputPageReference(); //Setting text value (if not still in view mode, now in edit) pref.Text = "4"; //Put an id to the control before render pref.ID = "pref1"; System.Text.StringBuilder result = new System.Text.StringBuilder(1024); pref.RenderControl(new HtmlTextWriter(new System.IO.StringWriter(result))); //Patch EPiServers webcontrol! Is this a bug? result.Replace("document.all['Hidden'].value,'Display','Hidden'", "document.all['" + pref.ID + "$Hidden'].value,'" + pref.ID + "$Display','" + pref.ID + "$Hidden'"); //Set the control, it could be just right to a pages form. In this case inside a webgrid's row event: e.Row.Columns["Source"].BeforeEditHtml = Server.HtmlEncode(result.ToString()) + result.ToString();