Solved

Global variable

Posted on 2010-11-23
19
399 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
ID: 34199045
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
ID: 34199078
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
ID: 34199081
Can you explain in a little more detail what it is you are trying to achieve?
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 83

Expert Comment

by:CodeCruiser
ID: 34199744
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
ID: 34200711
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
ID: 34203427
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
ID: 34204344
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
ID: 34204408
0
 
LVL 1

Author Comment

by:HLRosenberger
ID: 34204542
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
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 34204576
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
ID: 34204758
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
ID: 34204961
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
ID: 34223763
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
ID: 34223765
Thanks.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 34228919
How was the selected solution relevant to you?
0
 
LVL 1

Author Comment

by:HLRosenberger
ID: 34229637
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
ID: 34229651
You were talking about global button not variable.
0
 
LVL 1

Author Comment

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

Expert Comment

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

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

776 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