HTML form not adding query parameter to form submission URL

Eric Conklin asked on October 12, 2020 20:25

I am using a static html form on the sidebar to search the content of a page as such:

<form action="/carelink-search">
  <label for="searchtext">Search Carelink</label><br>
  <input type="text" id="searchtext" name="searchtext" value=""><br>
  <input type="submit" value="Submit">

This goes into a data source web part that adds the search parameter to the SQL query in the pages data source web part on that page as such:

('{%Querystring.searchtext #%}'='') OR (DocumentID IN (SELECT DocumentID FROM CMS_DocumentCategory WHERE BlogPostTitle LIKE '%{%Querystring.searchtext #%}%' ))

However, when submitting the form, nothing gets added to the end of the URL. It stays blank. Is there an easy way to ensure that the HTML GET request to that action will get processed correctly by Kentico?

When I manually add the searchtext='My search text here' parameter to the URL, it searches correctly but nothing gets added when submitting the form. Any help is appreciated.

Recent Answers

Dmitry Bastron answered on October 13, 2020 10:55

Hi Eric,

By the sound of your question, I'm guessing that you are using Kentico Portal Engine, which is based on ASP.NET Web Forms. This technology has a certain limitation, i.e. the entire page is a form (you can check this if you see the HTML source of the page). So, when you add a static HTML markup with form tag it basically inserts the form (your static search form) inside the other form (which is wrapping the page) and this is invalid HTML markup. The approach you are trying to use here is more like MVC and this will not work with Web Forms.

What you should do however is to create a new custom Web Part (.ascx), implement your logic inside button click event and place your web part on the sidebar or whenever you need (or add it globally into layout).

0 votesVote for this answer Mark as a Correct answer

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