Solved

Global variable

Posted on 2010-11-23
19
397 Views
Last Modified: 2012-05-10
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?  
0
Comment
Question by:HLRosenberger
19 Comments
 
LVL 5

Expert Comment

by:JayFromPep
Comment Utility
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
 
LVL 20

Accepted Solution

by:
BuggyCoder earned 500 total points
Comment Utility
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
 
LVL 52

Expert Comment

by:Carl Tawn
Comment Utility
Can you explain in a little more detail what it is you are trying to achieve?
0
 
LVL 83

Expert Comment

by:CodeCruiser
Comment Utility
If you want to click a button on another page from your current page then you would have to look for alternatives.
0
 
LVL 1

Author Comment

by:HLRosenberger
Comment Utility
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
 
LVL 83

Expert Comment

by:CodeCruiser
Comment Utility
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
 
LVL 1

Author Comment

by:HLRosenberger
Comment Utility
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
 
LVL 83

Expert Comment

by:CodeCruiser
Comment Utility
0
 
LVL 1

Author Comment

by:HLRosenberger
Comment Utility
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 83

Expert Comment

by:CodeCruiser
Comment Utility
Well the problem I see is

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

Obviously Unidentified is not equal to Identified!
0
 
LVL 1

Author Comment

by:HLRosenberger
Comment Utility
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
 
LVL 83

Expert Comment

by:CodeCruiser
Comment Utility
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
 
LVL 1

Author Comment

by:HLRosenberger
Comment Utility
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
 
LVL 1

Author Closing Comment

by:HLRosenberger
Comment Utility
Thanks.
0
 
LVL 83

Expert Comment

by:CodeCruiser
Comment Utility
How was the selected solution relevant to you?
0
 
LVL 1

Author Comment

by:HLRosenberger
Comment Utility
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
 
LVL 83

Expert Comment

by:CodeCruiser
Comment Utility
You were talking about global button not variable.
0
 
LVL 1

Author Comment

by:HLRosenberger
Comment Utility
But a global is a global, no?  Data type is irrelevant.
0
 
LVL 83

Expert Comment

by:CodeCruiser
Comment Utility
Data Type is relevant because not all variables hold data. Button is an object and contains data, functionality, and user interface.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now