i have a page where in the form load i initialize a server side variable with value and i want to render that value in js section. i am working with asp.net webform apps.
我有一个页面,在这个页面中,我用value初始化一个服务器端变量,我想在js部分中呈现这个值。我正在使用asp.net webform应用程序。
my server side page load code
string errblankEmail ="";
protected void Page_Load(object sender, EventArgs e)
{
errblankEmail ="Hello World";
}
if (str == '') {
alert('<% =errblankEmail %>');
}
when i run the page then i am getting error message like CS0103: The name 'errblankEmail' does not exist in the current context
当我运行这个页面时,我就会收到像CS0103这样的错误消息:在当前上下文中不存在“errblankEmail”这个名称
and i also saw that my page_load is not getting called because i set break point there. so guide me how to fix this problem. thanks
我还看到page_load没有被调用,因为我在那里设置了断点。所以指导我如何解决这个问题。谢谢
1 个解决方案
#1
3
You have to make the variable public
in order to access it.
为了访问变量,必须将其公开。
public string errblankEmail ="";
#1
3
You have to make the variable public
in order to access it.
为了访问变量,必须将其公开。
public string errblankEmail ="";