Solved

Site wide variable

Posted on 2009-05-04
8
217 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
  • 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
 

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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

760 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

19 Experts available now in Live!

Get 1:1 Help Now