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);
}
1
  • 1
    Remove script and function, you don't need put keyword there. ScriptManager handle them automatically Commented Apr 8, 2015 at 7:09

1 Answer 1

0

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

ScriptManager.RegisterClientScriptBlock(this, GetType(), "none", "xpopup();", false);
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.