Global variable

Does VB.NET have the concept of a variable that is global to my WEB app?  IF so, can I define a global variable that is of type BUTTON, and then set this variable on one WEB form and call it's CLICK event from another WEB form?  
LVL 1
HLRosenbergerAsked:
Who is Participating?
 
BuggyCoderConnect With a Mentor Commented:
Well you can definitely use global variables, either create as static type or use session variables.
Here are few articles on the same:-
http://dotnetperls.com/global-variables-aspnet
http://www.devasp.net/net/articles/display/323.html

Apart from this there are application variables kept specifically for
http://www.dotnetheaven.com/UploadFile/mahesh/ApplicationState05102005051501AM/ApplicationState.aspx

hope it helps
:-)
0
 
JayFromPepCommented:
I think what you really want to do is create a class.  global variables, as you described them, are really classes with pre-defined functionality that you can incorporate into an asp.net page, which is also a class.
0
 
Carl TawnSystems and Integration DeveloperCommented:
Can you explain in a little more detail what it is you are trying to achieve?
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
CodeCruiserCommented:
If you want to click a button on another page from your current page then you would have to look for alternatives.
0
 
HLRosenbergerAuthor Commented:
Yes, I want to click a button on another page from your current page.  I posted other questions here about this issue, but I cannot get this to work.  From Javascript, I want to click the button on another page.  
0
 
CodeCruiserCommented:
Are you loading the other page within a frame on current page? What is the functional requirement? Is the other page your own page? You can use query string to the other page and the page can execute code within the button based on query string when it loads.
0
 
HLRosenbergerAuthor Commented:
Actually, the one page is a popup and I just found out that a popup using showModalDialog can return a value.  So, now I'm returning a value and based on the value I need to call the click event of a button on the same page using JavaScript.
0
 
CodeCruiserCommented:
0
 
HLRosenbergerAuthor Commented:
That's the type of thing I have tried.  But my variable always comes back NULL, even though I am specifying the correct ID - at least I think so.

From the example, what does this mean:  TagsHelperConfig.FORM_TAGS_ENTRY_SUBMIT_BUTTON_ID

Here's my line of JavaScript and the HTML for my button:
var xx = window.document.getElementById('Unidentified_DocumentsRefreshButton');

<asp:ImageButton runat="server" id="Identified_DocumentsRefreshButton" causesvalidation="False" commandname="ResetData" imageurl="../Images/ButtonBarRefresh.gif" onmouseout="this.src='../Images/ButtonBarRefresh.gif'" onmouseover="this.src='../Images/ButtonBarRefreshOver.gif'" tooltip="&lt;%# GetResourceValue(&quot;Btn:Refresh&quot;, &quot;MyApp99&quot;) %>">

0
 
CodeCruiserCommented:
Well the problem I see is

...getElementById('Unidentified....
vs
...id="Identified...

Obviously Unidentified is not equal to Identified!
0
 
HLRosenbergerAuthor Commented:
I'm sorry.  There are two refresh buttons on the page - one for Identified and one for Unidentified.  And two corresponding buttons that when clicked display my popup.  Thus two places where I check the return value from the popup.  So, I merely copied and pasted the wrong HTML code.

So, this does not explain why its not working..
0
 
CodeCruiserCommented:
Check the html of the page when its rendered to see what is the name of the button. ASP.NET adds the parent container's name to the child controls' names.
0
 
HLRosenbergerAuthor Commented:
I found the problem:

This works:

var RefreshButton= window.document.getElementById("<%= Unidentified_DocumentsRefreshButton.ClientID %>");


This does not:

var RefreshButton= window.document.getElementById('Unidentified_DocumentsRefreshButton');
0
 
HLRosenbergerAuthor Commented:
Thanks.
0
 
CodeCruiserCommented:
How was the selected solution relevant to you?
0
 
HLRosenbergerAuthor Commented:
using global variables, which was part of my question.

And the answer to click the button I found on my own. (see my previous post)
0
 
CodeCruiserCommented:
You were talking about global button not variable.
0
 
HLRosenbergerAuthor Commented:
But a global is a global, no?  Data type is irrelevant.
0
 
CodeCruiserCommented:
Data Type is relevant because not all variables hold data. Button is an object and contains data, functionality, and user interface.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.