Calling javascript from code behind not working as expected

Mr Java99

So I was making a page for creating accounts and saving them inside a database. To check if the code is working, I added debug messages between some lines of code using:

ScriptManager.RegisterStartupScript(this, GetType(),
                "textas", "alert('test')", true);

The problem is that it turned out that having two debug messages will cause the page to not display any of them. I tested a simple code in an another page (shown below) and got the same problem. I also realized that showing one message will eventually make the code stop at where the debug message was, so any code that comes after won't run.

        protected void test_Click(object sender, EventArgs e)
        {
            ScriptManager.RegisterStartupScript(this, GetType(),
                "textas", "alert('test')", true);
            ScriptManager.RegisterStartupScript(this, GetType(),
                "textasd", "alert('test1')", true);
        }

Am I missing something or is that some kind of bug?

wazz

Try adding semicolons to the end of the js statements.

ScriptManager.RegisterStartupScript(this, GetType(),
    "textas", "alert('test');", true);
ScriptManager.RegisterStartupScript(this, GetType(),
    "textasd", "alert('test1');", true);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

JavaScript: Not calling javascript function from the code behind

From Dev

Dynamically created JavaScript code from Code behind not working on javascript

From Dev

("NetworkError: 401 Unauthorized) Calling code behind method from JavaScript

From Dev

Calling JavaScript function from code behind after Response.End()

From Dev

Calling javascript function from C# code behind

From Dev

javascript function not calling from code behind when i'm calling another function within same click event

From Dev

Calling SignalR Hub method from code behind

From Dev

Javascript regex code not working as expected

From Dev

Calling Service From Broadcastreceiver not working as expected

From Dev

Xamarin FontAwesome not working from code behind

From Dev

Listview isvisible property is not working from the code behind?

From Dev

WPF Localization not working from code behind

From Dev

Calling javascript from codebehind not working

From Dev

Code behind button only posting back, not calling javascript function

From Dev

Calling code behind functions from ajax call and display item by item

From Dev

Calling a jquery function from code behind doesnt work

From Dev

WPF MVVM calling ViewModel methods from code behind

From Dev

Negative lookup behind not working as expected

From Dev

Why my javascript code is not working as expected

From Dev

Javascript function is not being called from code behind

From Dev

Pass a value to javascript from code behind

From Dev

Call Code Behind Function from JavaScript (not AJAX!)

From Dev

Populate javascript gallery from code behind

From Dev

Trigger JavaScript Confirm() from code behind

From Dev

Javascript method call from code behind

From Dev

How to call Javascript method from code behind

From Dev

Passed variable from code behind to javascript not updating

From Dev

How to pass a value from JavaScript to code behind?

From

Why Calling Setenv from code Not Working?

Related Related

  1. 1

    JavaScript: Not calling javascript function from the code behind

  2. 2

    Dynamically created JavaScript code from Code behind not working on javascript

  3. 3

    ("NetworkError: 401 Unauthorized) Calling code behind method from JavaScript

  4. 4

    Calling JavaScript function from code behind after Response.End()

  5. 5

    Calling javascript function from C# code behind

  6. 6

    javascript function not calling from code behind when i'm calling another function within same click event

  7. 7

    Calling SignalR Hub method from code behind

  8. 8

    Javascript regex code not working as expected

  9. 9

    Calling Service From Broadcastreceiver not working as expected

  10. 10

    Xamarin FontAwesome not working from code behind

  11. 11

    Listview isvisible property is not working from the code behind?

  12. 12

    WPF Localization not working from code behind

  13. 13

    Calling javascript from codebehind not working

  14. 14

    Code behind button only posting back, not calling javascript function

  15. 15

    Calling code behind functions from ajax call and display item by item

  16. 16

    Calling a jquery function from code behind doesnt work

  17. 17

    WPF MVVM calling ViewModel methods from code behind

  18. 18

    Negative lookup behind not working as expected

  19. 19

    Why my javascript code is not working as expected

  20. 20

    Javascript function is not being called from code behind

  21. 21

    Pass a value to javascript from code behind

  22. 22

    Call Code Behind Function from JavaScript (not AJAX!)

  23. 23

    Populate javascript gallery from code behind

  24. 24

    Trigger JavaScript Confirm() from code behind

  25. 25

    Javascript method call from code behind

  26. 26

    How to call Javascript method from code behind

  27. 27

    Passed variable from code behind to javascript not updating

  28. 28

    How to pass a value from JavaScript to code behind?

  29. 29

    Why Calling Setenv from code Not Working?

HotTag

Archive