SaaS CMS has officially launched! Learn more now.

Hello !! about xforms (adding few fields in it)

Vote:
 

Hello everyone,

I have a user control which hold 4-5 text box control. I have to add this control before when xform shows the xform controls
Also. I have to add one more additional field at the end of xform templates, so the Xform should look like this

1.  myfield1  textbox1
2.  myField2  Textbox2
3.  Xforms Fields
4.  mySummary textbox

In other words: if my xform contains 5 fields from the editor, I need to add 4-5 fields on to the top of it and one more field at the end.
Ideally it should display those textboxes at the top and bottom when the xform gets loaded. When i hit the submit button, it should save the contorl content in the epi-server database as xform contents, So that, it can be ne refilled from epi-server when i load the form on edit mode using episerver.

Any bright ideas or sample code. Please help.

Thanks.

#39601
May 24, 2010 17:57
Vote:
 

Not sure if this will help you, but I had to do something similar. Edit your FormPanel <asp:Panel> control by adding your custom textboxes. Then you need to add your own submit button so you can add your custom field information to the same database.

Edit FormPanel

<asp:Panel runat="server" ID="FormPanel" CssClass="xForm" DefaultButton="submit" >
    <asp:TextBox ID="customField1"  ToolTip="customField1" runat="server"></asp:TextBox>  <-- custom fields
    <xforms:xformcontrol ID="FormControl" runat="server" EnableClientScript="true" ValidationGroup="XForm" />
    <p>&nbsp;</p>
    <asp:Button OnClick="buttonSubmit" EnableViewState="true" Text="Submit" ID="submit" runat="server" />  <-- custom submit button fires "buttonSubmit" method on click.
    <p>&nbsp;</p>
</asp:Panel>

 

Codebehind:

protected void buttonSubmit(object sender, EventArgs e)
{
   FormControl.SubmitForm(ChannelOptions.Database);
}

private void SetupForm()
{
  FormControl.FormDefinition = Form;
  FormControl.BeforeSubmitPostedData += new SaveFormDataEventHandler(FormControl_BeforeSubmitPostedData);
}

Add code to send custom text fields to data

public void FormControl_BeforeSubmitPostedData(object sender, SaveFormDataEventArgs e)
{
     e.FormData.SetValue("CustomField", "SomeValue");  <<-- set your custom value here
}

#39621
May 25, 2010 19:47
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.