3

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.

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

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

1 Answer 1

3

You have to make the variable public in order to access it.

public string errblankEmail ="";
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.