How to create dynamic form using Javascript and Submit it in ASP.Net ?


Dear friends ,

sometimes you need to create dynamic form in . Let see below example to understand it more clearly.

Suppose on a  button click you want pass token value to a different  handler page then you need to write following lines

<script type="text/javascript">

function callPagePostBack(accessToken) {

var form = document.createElement("form");
            form.setAttribute("method", ‘post’);
            form.setAttribute("action", ‘LoginAuthentication.ashx’);

            var field = document.createElement("input");
            field.setAttribute("type", "hidden");
            field.setAttribute("name", ‘accessToken’);
            field.setAttribute("value", accessToken);




When you run above code you will find on LoginAuthentication.ashx folder you are getting accessToken there.


I hope you enjoyed this tutorial.

Thanks ,

Rajat Jaiswal