1

I want to store form details and display a popup box, when I click the submit button. For this I use try { } finally { } but how to link popup box function in JavaScript to the C# file?

JavaScript:

<script>
function xpopup() {
    document.getElementById("x").onclick = function () 
    {
        var overlay = document.getElementById("overLay");
        var popup = document.getElementById("xPopup");
        overlay.style.display = "block";
        popup.style.display = "block";
    }
}
</script>

C#:

try { }
finally
{
    ScriptManager.RegisterClientScriptBlock(this, GetType(), "none", "<script>function xpopup();</script>", false);
}
Knerd
  • 1,892
  • 3
  • 28
  • 55
arun
  • 19
  • 1
  • 5
  • 1
    Remove script and function, you don't need put keyword there. ScriptManager handle them automatically – Peyman Apr 08 '15 at 07:09

1 Answers1

0

Remove the <script> tag and function keyword as the function is already been defined:

ScriptManager.RegisterClientScriptBlock(this, GetType(), "none", "xpopup();", false);
VMAtm
  • 27,943
  • 17
  • 79
  • 125