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 is the use of data set in asp.net?

493


Explain page output caching?

528


If I am developing an application that must accomodate multiple security levels though secure login and my asp.net web application is spanned across three web-servers (using round-robin load balancing). What would be the best approach to maintain login-in state for the users?

649


how to transfer the file from client to server using asp.net

593


How can you register a custom server control to a web page?

549






Explain the difference between sql invalidation and sql notification.

559


Explain what is event bubbling?

576


What are the server control tags in asp.net.?

625


What is the part of url?

534


What is a url string?

551


Explain diff. Between friend and protected friend?

500


How can we inherit a static variable?

545


How to rename a table using sql queries?

572


Explain the difference between page.registerclientscriptblock and page.registerstartupscript?

577


Explain global assembly cache.

579