Link to home
Start Free TrialLog in
Avatar of HLRosenberger
HLRosenbergerFlag for United States of America

asked on

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?  
Avatar of JayFromPep
JayFromPep
Flag of United States of America image

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.
ASKER CERTIFIED SOLUTION
Avatar of BuggyCoder
BuggyCoder
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Carl Tawn
Can you explain in a little more detail what it is you are trying to achieve?
If you want to click a button on another page from your current page then you would have to look for alternatives.
Avatar of HLRosenberger

ASKER

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.  
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.
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.
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;) %>">

Well the problem I see is

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

Obviously Unidentified is not equal to Identified!
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..
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.
I found the problem:

This works:

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


This does not:

var RefreshButton= window.document.getElementById('Unidentified_DocumentsRefreshButton');
Thanks.
How was the selected solution relevant to you?
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)
You were talking about global button not variable.
But a global is a global, no?  Data type is irrelevant.
Data Type is relevant because not all variables hold data. Button is an object and contains data, functionality, and user interface.