To be more clear, I am trying to modify the Form autogenerated by Sharepoint which you can see in Sharepoint Designer under Workflows -> Your Workflow -> Forms

By default you are given two buttons which is start and cancel which is self explainable, Start starts the workflow and Cancel does nothing.

Once I click on either of the buttons processing happens on the background but nothing interactive happens on the UI (I am expecting for it to go back on the sharepoint list and have a refreshed data or at least close the form). How do I make it close the form? The code behind for the buttons is
<td nowrap="nowrap" class="ms-vb">
<input type="button" value="Start" name="btnSave" onclick="javascript: {ddwrt:GenFireServerEvent(concat('__insert;__commit;__redirectsource;__redirectToList={',ddwrt:EcmaScriptEncode($ListName),'};'))}" />
</td>
<td nowrap="nowrap" class="ms-vb" width="99%">
<input type="button" value="Cancel" name="btnCancel" onclick="javascript: {ddwrt:GenFireServerEvent(concat('__cancel;__redirectsource;__redirectToList={',ddwrt:EcmaScriptEncode($ListName),'};'))}" />
</td>
Even theres a redirecttolist parameter on the built in javascript I does not redirect. Any known workaround for this one? Or anything I am doing wrong?
Edit – the first issue is now solved
But I still have a slight problem as I dont know how to dynamically (not hard coded) pass TemplateID and ListID. With ItemID I use {ItemId} that works fine. To further illustrate what I mean see the screenshot and the comments below.

Have you tried passing your workflow form ASPX page the
SourceURL parameter?Ex:
.../MyWorflowPage.aspx?Source=http://sharepointserver/site/