Why can not find my code behind variable in c #?

0

I want to get a variable from my code behind in c # but I get the following error:

Compiler Error Message: CS0103: The name 'qrp' does not exist in the current context

But if I correctly declare my variable:

 public string qrp { get; set; }

I try to print on an alert as follows:

  alert("<%= qrp.ToString() %>");

but I get the error from the top, the variable I declare up to the bottom of where the class starts and the filling when going through a method.

    
asked by David 16.05.2018 в 22:24
source

1 answer

-1

use ViewBag , example:

ViewBag.qrp = "valor";

and the part of the front you call it this way

alert('@ViewBag.qrp');
    
answered by 17.05.2018 в 00:30