dimanche 5 avril 2015

the javascript function can't be called when the page postback


Vote count:

0




I am trying to call a javascript function as you can see here :



<script language="javascript" type="text/javascript">
function postRefId(refIdValue) {
var form = document.createElement("form");
form.setAttribute("method", "POST");
form.setAttribute("action", "<% System.Configuration.ConfigurationManager.AppSettings["PgwSite"].ToString(); %>");
form.setAttribute("target", "_self");
var hiddenField = document.createElement("input");
hiddenField.setAttribute("name", "RefId");
hiddenField.setAttribute("value", refIdValue);
form.appendChild(hiddenField); document.getElementById("bankform").appendChild(form);
form.submit();
document.getElementById("bankform").removeChild(form);
}
</script>


I put the part of code inside contentplaceholder .as you can see the function expects refIdValue ,so i should generate this value in code behind and pass it to this function ,so i create a button to generate the refIdValue :



Session.Add("post", "<script language='javascript' type='text/javascript'> postRefId('" + resultArray[1] + "');</script>");


In the html page i put this part of code .



<%
if (Session["post"] != null)
{
string ss = Session["post"].ToString();
Response.Write(Session["post"].ToString());
}
%>


after calling the function the page should be redirected ,but the page is refreshed and noting happens ,.why ?



asked 27 secs ago







the javascript function can't be called when the page postback

Aucun commentaire:

Enregistrer un commentaire