where is declare global variable in asp.net and what is use
of global variable

Answer Posted / sridhar

For Classes to be generally consumable across your site you should place them in APP_CODE folder.
This simple class will provide global variable

imports Microsoft.VisualBasic
Public Class Sample
Public Shared Text as String ="Global Variable Example"
End Class

Using it in a page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
Me.Title = Sample.Text
End Sub

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What do you mean by serialize and marshalbyref?

766


What is the good practice to implement validations in aspx page?

843


How would you turn off cookies on one page of your website?

723


How do I open an ashx file?

760


What is the difference between session and viewstate?

717


What are the data controls available in asp.net?

709


What are Master Pages in ASP.NET? or What is a Master Page?

830


Explain page output caching?

746


What is the difference between visual basic and asp.net?

743


What does asax stand for?

744


What is the caspol.exe tool used for?

748


Define application state variable and session state variable?

780


What is bound controls

783


What is a web api? Which protocol is used in a web api?

752


How response object is related to asp's response object?

701