Reference custom list form fields from code behind and automatically fill them with values.
- by Janis Veinbergs
Hello.
I`v made my custom NewForm.aspx for my list and I want to add some custom code to it. So I inherit that form from my own class:
public class MyCustomNewForm : Microsoft.SharePoint.WebPartPages.WebPartPage
Now I want to reference some of available fields to automatically fill them for user. (Javascript won't help here as I have to get some data from other lists).
But I have no idea how do I reference these fields from codebehind files.
The code for control field is written (well, it was generated by Sharepoint Designer when using command Insert SharePoint Controls Custom List Form...) in .aspx page like this:
<SharePoint:FormField runat="server" id="ff1{$Pos}" ControlMode="New" FieldName="Title" __designer:bind="{ddwrt:DataBind('i',concat('ff1',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Title')}"/>
When looking at id at runtime, it is insanely long
So how do i reference fields, so I could set Text property on them in my codebehind file?