Post form data to other page

joyanta sen asked on November 8, 2018 07:24

Hi, I have cloned the LogonMiniForm and I need to post the form's fields( UserName, Password Textboxes) value to some external url. I have put the external url in Default Redirect URL property of the user control. But when I click the button it is going to the external url but not able to see the posted form field's value, while checking in the Form Data under Network tab(chrome).

The Form tag is in PortalTemplate.aspx,so I have put another Form tag in the user control without keeping runat="server" property. And I also tried without keeping this form tag in the user control but result was the same.

Could you please help me on how to post form field value.

Thanks.

Recent Answers


Juraj Ondrus answered on November 8, 2018 08:28

Hi,
The redirect URL just does redirect and no data are posted. You may need to adjust the code of the web part and add the custom logic to read the submitted data and pass them to the external service you need.

0 votesVote for this answer Mark as a Correct answer

Michal Samuhel answered on November 8, 2018 09:44

There is a misunderstanding on Redirect property functionality. It should only redirect to different URL after a form is submitted and form data is inserted into database via control itself. If you want to post data to another page, easiest is to leverage an event handler from

https://docs.kentico.com/k11/custom-development/handling-global-events/reference-global-system-events#Reference-Globalsystemevents-BizFormItemEvents

And use a code like:

private void BizForm_Insert_After(object sender, BizFormItemEventArgs e)
    {
        string url = "google.com";

        var content = new StringContent(e.Item.ToString(), Encoding.UTF8);

        HttpClient client = new HttpClient();
        client.PostAsync(url, content);

    }
1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.