How to pass String Argument to javascript function

Arrow

This is my front-end:

ImageButton Details = (ImageButton)e.Row.FindControl("iBtnDetails");//take lable id
                String strApplication1 = Details.CommandArgument.ToString();

                e.Row.Attributes["onmouseover"] = "this.style.cursor='hand';this.style.textDecoration='underline';";
                e.Row.Attributes["onmouseout"] = "this.style.textDecoration='none';";
                e.Row.Attributes.Add("onClick", "SelectRow()");

This is my back-end:

<script type="text/javascript">
                function SelectRow() {

                    var strApplication1 = '<%=strApplication1%>'

                    if (strApplication1 == "IT Application Request")
                    {

                         window.open('http://.aspx', '_blank');
                    }

                    else if (strApplication1 == "IT Account Request")
                    {
                         window.open('http://.aspx', '_blank');

                    }
                    else if (strApplication1 == "Change Control Management")
                    {
                         window.open('http://.aspx', '_blank');
    }
                    else if (strApplication1 == "Backup & Restore")
                    {
                        window.open('http://.aspx', '_blank');
                    }
                }

</script>

I want to pass String Argument to javascript function, but I got error that strApplication1 doesn't exist in the current context.

Jon P

You need to make strApplication1 a public property on your page class. Currently, it is just an internal variable.

Something like:

public partial class YourPage : System.Web.UI.Page
{
    public string strApplication1 {get; set;}

    protected void Page_Load(object sender, EventArgs e)
    {
         //Your page logic          
    }

    //Looks like you set the variable in an onDatabound or similar.
    //So use this where you currently set the variable
    strApplication1 = Details.CommandArgument.ToString();

}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to pass a string as an argument to a javascript function

From Dev

How to pass a string as argument JavaScript function?

From Dev

How to pass a function as an argument to a custom function in Javascript

From Dev

How to pass a Javascript function as an argument in Javascript Interface?

From Dev

Python: how pass string as a function's argument

From Dev

How to pass argument to javascript anonymous function

From Dev

How to pass argument to "then" function

From Dev

How to pass argument to "then" function

From Dev

How to pass a self invoking function as a function argument in JavaScript?

From Dev

How do I pass a Java function a String[] argument?

From Dev

In VBA, how to split a string into an array, then pass it as an argument to a Sub or Function

From Dev

How do I pass a Java function a String[] argument?

From Dev

how to pass argument as string outside which should execute particular function

From Dev

How to pass interpolated value as an argument into a javascript function in angularjs

From Dev

In Javascript or Jquery How to pass external json file as argument to a function?

From Dev

How to pass the argument to the promise function in the JavaScript for-each cycle

From Dev

How to pass String Variable in Javascript Function?

From Dev

How to pass a string to the Javascript function from HTML?

From Dev

How to pass Javascript as a string to function from HTML

From Dev

How to pass a function as an argument, with arguments?

From Dev

How to pass a function as argument in Rust

From Dev

How to pass an array as function argument?

From Dev

How to pass layout as a function argument

From Dev

How to pass an array as function argument?

From Dev

How to pass a function as an argument, with arguments?

From Dev

Can not pass a string as function argument Jquery

From Dev

In JavaScript, how do I access a function on an object using a string argument?

From Dev

How to pass the result of a function as argument into a Bash function?

From Dev

Pass variable from php to javascript function argument

Related Related

  1. 1

    How to pass a string as an argument to a javascript function

  2. 2

    How to pass a string as argument JavaScript function?

  3. 3

    How to pass a function as an argument to a custom function in Javascript

  4. 4

    How to pass a Javascript function as an argument in Javascript Interface?

  5. 5

    Python: how pass string as a function's argument

  6. 6

    How to pass argument to javascript anonymous function

  7. 7

    How to pass argument to "then" function

  8. 8

    How to pass argument to "then" function

  9. 9

    How to pass a self invoking function as a function argument in JavaScript?

  10. 10

    How do I pass a Java function a String[] argument?

  11. 11

    In VBA, how to split a string into an array, then pass it as an argument to a Sub or Function

  12. 12

    How do I pass a Java function a String[] argument?

  13. 13

    how to pass argument as string outside which should execute particular function

  14. 14

    How to pass interpolated value as an argument into a javascript function in angularjs

  15. 15

    In Javascript or Jquery How to pass external json file as argument to a function?

  16. 16

    How to pass the argument to the promise function in the JavaScript for-each cycle

  17. 17

    How to pass String Variable in Javascript Function?

  18. 18

    How to pass a string to the Javascript function from HTML?

  19. 19

    How to pass Javascript as a string to function from HTML

  20. 20

    How to pass a function as an argument, with arguments?

  21. 21

    How to pass a function as argument in Rust

  22. 22

    How to pass an array as function argument?

  23. 23

    How to pass layout as a function argument

  24. 24

    How to pass an array as function argument?

  25. 25

    How to pass a function as an argument, with arguments?

  26. 26

    Can not pass a string as function argument Jquery

  27. 27

    In JavaScript, how do I access a function on an object using a string argument?

  28. 28

    How to pass the result of a function as argument into a Bash function?

  29. 29

    Pass variable from php to javascript function argument

HotTag

Archive