Category Archives: JavaScript

JavaScript

How to Pass Value across Application or Post to url

To post value across Application or Post to url.
Write the below code on the Source application.

<script>
        function post_to_url(path, params, method) {
            method = "post"; // Set method to post by default, if not specified.            
            var form = document.createElement("form");
            form.setAttribute("method", method);
            form.setAttribute("action", path);
            form.setAttribute("target", "_blank");
            var hiddenField = document.createElement("input");
            hiddenField.setAttribute("type", "hidden");
            hiddenField.setAttribute("name", "ValueName");
            hiddenField.setAttribute("value", params);
            form.appendChild(hiddenField);
            document.body.appendChild(form);
            form.submit();
        }
</script>

Event on which you want to post the value. Write the below code on the event.

ClientScript.RegisterStartupScript(this.GetType(), "hwa", "post_to_url('http://Page Url','" + Value to Pass + "','post');", true);

How to get value on other Application.
Write the below code on Destination Application

String Value = Request.Form["ValueName"];