Click here to Skip to main content
15,894,740 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
hi there,


in my website there is home page is in .net page and second one is in C# so

i want to create global variable to fetch data from .net page to c# page.


thanks,
Posted
Comments
PIEBALDconsult 8-Dec-13 23:49pm    
Don't; it's a bad idea, find a better solution.
[no name] 8-Dec-13 23:56pm    
so suggest me better solution.
Sergey Alexandrovich Kryukov 9-Dec-13 0:46am    
Strictly speaking, you cannot talk about "solution", unless you formulate your request correctly. Not that "global variable" is a bad idea: there is no such thing in .NET, and something close to it would be 1) bad idea, 2) would not solve the problem with communication between pages which you probably kept in mind but did not even mention. You should not reasonably formulate your questions like "I want", it won't always make sense.

Please see my answer where I explain something which you probably really need.

—SA
Harshil_Raval 9-Dec-13 0:23am    
what you mean by .net page and c# page?

First of all, formally, this is not a question, but is an invalid request. Here is why: there is not such concept as "global variable" in .NET, and, hence, in ASP.NET, and this is one of the best features of the framework. The closest, in a functional sense, would be the concept of "public static field of a class or a structure", which is not the same and also should not be recommended.

Informally, however, your problem would make sense if you formulated it in some other way. As this is ASP.NET, the problem is the stateless nature of HTTP protocol and a need to preserve the state. Please see:
http://en.wikipedia.org/wiki/Stateless_protocol[^],
http://en.wikipedia.org/wiki/Http#HTTP_session_state[^].

You can start here: http://msdn.microsoft.com/en-us/library/ms178581.aspx[^].

—SA
 
Share this answer
 
Comments
Abhinav S 9-Dec-13 1:16am    
5.
Sergey Alexandrovich Kryukov 9-Dec-13 1:24am    
Thank you, Abhinav.
—SA
Use session state to store date that you may need to host for an entire session.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 9-Dec-13 0:33am    
What if I vote 4 this time? ;-) This provide the answer, but not quite sufficient. First of all, it would be important to dismiss the OP's misconception about "global variables". What you are talking about is most likely what OP needs, but is a very different topic.
Please see my answer.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900