Solved

Site wide variable

Posted on 2009-05-04
8
221 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 500 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

726 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