?
Solved

Site wide variable

Posted on 2009-05-04
8
Medium Priority
?
227 Views
Last Modified: 2013-11-26
I need to set a path sitewide on web site load so that I can use an images path whatever page is loaded.

All pages reference a Masterpage by the way.
0
Comment
Question by:lrbrister
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 1

Expert Comment

by:chuckdsc
ID: 24295377
in VB.Net create a module which is accessible across the solution and create a public variable to store the value.

Module Module1
    Public moduleinteger As Integer
End Module


in C# create a public static class and create a public static variable to store the values which can be accessed anywhere in the project

namespace ModuleTest
{
        public static Module1
        {
                public static int moduleinteger;
        }
}
0
 

Author Comment

by:lrbrister
ID: 24295906
chuckdsc:


I need to set a variable as follows

dim _path as string = ""
_path="http://seg.mydomain.com/images"

Then be able to use it on a page with
<%#_path%> ---not sure about the syntax on that line
0
 
LVL 1

Expert Comment

by:chuckdsc
ID: 24296460
lrbrister:

correct me otherwise,

 let me assume you are using an image control
then you can do it like this

dim _path as string = "http://seg.mydomain.com/images"
Image1.ImageUrl = _path & "<image>"

0
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 

Author Comment

by:lrbrister
ID: 24296559
chuckdsc:

That's correct.  I need that _path to be available on any page.

However...the datasource is nopt called from code behind but with a connection string.

So the actual image on the aspx page looks like this

<img src="http://seg.mydomain.com/imagesCMS/large/<%#Eval("ImageSrc")%>" alt="" width="170px" />
0
 
LVL 1

Expert Comment

by:chuckdsc
ID: 24296786
lrbrister:

Try changing the src like this

#Eval("imgfil", "http://seg.mydomain.com/imagesCMS/large/{0}.jpg")

let me know how it works
0
 
LVL 1

Expert Comment

by:chuckdsc
ID: 24296792
#Eval("ImageSrc", "http://seg.mydomain.com/imagesCMS/large/{0}.jpg")
0
 

Author Comment

by:lrbrister
ID: 24314003
chuckdsc
In your answer at the top you have
dim _path as string = "http://seg.mydomain.com/images"

how do I make that _path load at login and be available on every page in the site?
0
 
LVL 1

Accepted Solution

by:
chuckdsc earned 2000 total points
ID: 24322266
lrbrister:

in VB.Net, create a public module, it can be accessed anywhere in the application as it creates a global scope for the variables declared with public

refer the following MSDN article

http://msdn.microsoft.com/en-us/library/aaxss7da.aspx


0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

771 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